In order to load images from files into textures, you can use the image asset. It uses the load-image API to convert its input into a texture. You may also pass any number of arguments to the asset that will be forwarded to the texture construction, as well as the special arguments texture-class to specify another class for the resource, and type to provide a specific input image format type.

The type will be passed on to load-image, which takes either a keyword of the image type name, a mime-type, or a string that will be converted to the type name for you.

If you need to dynamically construct image textures from a source, you can also do so via the image-loader without needing to tie the image to an asset.

Trial also provides a few convenience functions to deal with image data:

Disposing of the input data

Some image loaders will return statically allocated pixel data that needs to be manually freed. The image will automatically free this as soon as its associated texture has been loaded. If you manually use the image-loader, it is up to you to call deallocate on the sources of the returned texture when appropriate.