Is it true there's no way to get an NSImage directly from a SwiftUI Image? Seems weird since Image can be created from NSImage.
Seems the solution is to load the asset as an NSImage and go from there.
Is it true there's no way to get an NSImage directly from a SwiftUI Image? Seems weird since Image can be created from NSImage.
Seems the solution is to load the asset as an NSImage and go from there.
@puppethead SwiftUI's Image is a view, not an object like NS/UIImage.
@nicoreese @puppethead It's *also* a View, like other more model like things, e.g. Color. But it's also an Image in the original sense.
I think they chose not to expose the underlying representation because UIImage and NSImage are really different and at least the latter can be problematic thread transfer wise.
@puppethead I’ve never had to go in this direction before. CGImage as an intermediary maybe?
@mattiem I went with loading as NSImage, and then creating Image from that. Slightly more complicated to load NSImage from an asset catalog, especially since I'm tinkering with a screensaver which isn't the main bundle.
@twostraws has a good writeup on converting between image formats, although NSImage is missing. 😀
https://www.hackingwithswift.com/books/ios-swiftui/integrating-core-image-with-swiftui