Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Priya Raman
Priya Raman

Posted on • Edited on

SwiftUI - Basic Core Image Processing

Steps to create a processed image based on CI filter in SwiftUI

  1. Create CIFilter instance to be sepia or any filter type.
  2. Convert selectedItem - PhotosPickerItem into Data format using loadTransferable method.
  3. Convert imageData into UIImage
  4. For Core Image processing, Image needs to be in CI format, so convert UIImage into CIImage.
  5. CIFilter is a specific container within Core Image that can accept input CI image and generate output CI image and apply filter in between.
  6. Set CurrentFilter's CI inputImg using setValue with Img key.
  7. Set CurrentFilter's intensity or any valid inputKeys with respective float value
  8. Fetch CurrentFilter's CI outputImg
  9. Now that processing within CI is over, its time to convert that to proper pixels in Coregraphics.
  10. CIContext can create cgImage with this generated CIImage with applied filter to the fullest extent size.
  11. Back convert from CGImage to UIImage as CIImage conversion is not needed as image has been processed.
  12. Back convert from UIImage to Image initializer in SwiftUI.

My Notes as understood from HackingWithSwift 100 days of SwiftUI.

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

Notes for my own reference given my forgetfulness!!
  • Joined

More fromPriya Raman

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp