CIKernelで生成した画像はSwiftUIのImageで表示できない?

p0dee
2 min readMay 31, 2020

--

Core Imageを用いたSwiftUIアプリを作成して、ある問題に直面した。それは、CIKernelから生成した画像が、なぜかImageに表示されないというもの。

Core Imageは習熟しておらず、CIKernelで画像フィルタを作成すのも今回が初めて。そんな付け焼き刃の知識のなかで、ひとつ手がかりが掴めた。

  • SwiftUI.Imageに表示できる: UIImage(UIImage(named:), Core Graphicsで描画生成したものには、image.cgImageが存在するが、image.ciImagenil
  • SwiftUI.Imageに表示できない: CIKernelで生成したCIImageにより初期化したUIImageには、image.cgImagenilだが、image.ciImageは存在する

SwiftUI.Imageに渡すUIImageにはCGImageが必要なのだろうか?

この記事が参考になりそうなので、勉強してみる。

https://www.hackingwithswift.com/books/ios-swiftui/integrating-core-image-with-swiftui

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

No responses yet

Write a response