Since macOS 15.2 we can use Image Playground in our applications. The users love to generate an image with Apple Intelligence. Whether you need a cool image to add to a social post, a placeholder image for some operation, the AI can just generate something based on a few keywords.
Our ImagePlaygroundMBS class provides a few methods to handle this. You make an instance, configure it with maybe a few concept phrases, a source image and then show it. We recommend to show it from a button somewhere in the user interface. You implement the events and the CreatedImage event will provide the folderitem to the image file. Just load and display like our example project.
Here is a sample code to show the panel with two concept texts added:
Var controller As New ImagePlaygroundMBS
controller.AddConcept "Cat"
controller.AddConcept "New Year"
controller.Present
You may need to subclass the ImagePlaygroundMBS class to add the CreatedImage event or use AddHandler to connect it to a method in your window and receive the new image. The pictures arrive as HEIC files with 1024x1024 pixel in size as far as we see.
Sub CreatedImage(file as FolderItem)
MainWindow.ShowPicture Picture.Open(file)
End Sub
Please try with 24.6pr4 plugin and check the example project. Maybe before, check system preferences to enable Apple Intelligence if possible.