Help us understand the problem. What is going on with this article?

image filter template w/ swift

More than 5 years have passed since last update.
//
//  TopViewController.swift
//
//  Created by Yusuke Sugomori on 9/9/14.
//  Copyright (c) 2014 Yusuke Sugomori. All rights reserved.
//

import UIKit

class TopViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.


        let screenSize: CGRect = UIScreen.mainScreen().bounds

        let screenWidth = screenSize.width
        let screenHeight = screenSize.height

        let image = UIImage(named: "test.jpg")

        // Core Image context
        let ciContext = CIContext(options: nil)

        // CIImage, think of a CIImage as image data for processing, nothing is displayed or can be displayed at this point
        let coreImage = CIImage(image: image)

        // pick the filter
        let filter = CIFilter(name: "CIPhotoEffectTransfer")

        // pass image as input
        filter.setValue(coreImage, forKey: kCIInputImageKey)

        // retrieve the processed image
        let filteredImageData = filter.valueForKey(kCIOutputImageKey) as CIImage

        // returns a Quartz image from the Core Image context
        let filteredImageRef = ciContext.createCGImage(filteredImageData, fromRect: filteredImageData.extent())

        // final UIImage ready to be displayed
        let filteredImage = UIImage(CGImage: filteredImageRef)


        let imageView = UIImageView(image: filteredImage)

        imageView.frame = CGRectMake(0, 0, screenWidth, screenHeight)
        imageView.contentMode = UIViewContentMode.ScaleAspectFit

        self.view.addSubview(imageView)

    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away