Images are defined in portfolios as a prerequisite to defining a texture. The most convenient way to import images into Visualize is to using the HPS::Image::File::Import function, although it is possible to use a programmatically-defined or generated image as texture data. Any byte array will work. Image files are loaded synchronously by Visualize, so if you expect image loading to take a long time, you should use a separate worker thread. The only requirements to specify when loading images are the filename and the image format. Any problems associated with loading an image will be reported using an HPS::IOException.
HPS::Portfolio::DefineImage expects an HPS::ImageKit object as a parameter, which is returned by HPS::Image::File::Import. When defining an image in this way, only the image format and filename must be provided. However, it is possible to define an HPS::ImageKit manually. When defining images that are loaded without the use of HPS::Image::File::Import, the dimensions, the image format, and the image data itself must be supplied so that the kit can be composed. That operation is described below:
Saving a screenshot as an image
Visualize allows you to save a screenshot of your rendering result into an HPS::ImageKit. The data is initially preserved in RGB form, but the image kit is able to convert to other file formats if necessary. You are also able to simply inspect the data if you don't need to write it to a file. An example of this operation is as follows:
Once you have the data in a buffer, you can write it to a file, inspect it, or do whatever you need to with it. Note that in order for this to work, you must have previously called HPS::WindowKey::Update at least once on the window key you wish to snapshot.