Magnum::Trade::OpenExrImporter class new in Git master

OpenEXR importer plugin.

Supports single-part OpenEXR (*.exr) images with half-float, float and unsigned integer channels. You can use OpenExrImageConverter to encode images into this format.


This plugin depends on the Trade library and is built if WITH_OPENEXRIMPORTER is enabled when building Magnum Plugins. To use as a dynamic plugin, load "OpenExrImporter" via Corrade::PluginManager::Manager.

Additionally, if you're using Magnum as a CMake subproject, bundle the magnum-plugins repository and do the following. Using OpenEXR itself as a CMake subproject isn't tested at the moment, so you need to provide it as a system dependency and point CMAKE_PREFIX_PATH to its installation dir if necessary.

add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL)

# So the dynamically loaded plugin gets built implicitly
add_dependencies(your-app MagnumPlugins::OpenExrImporter)

To use as a static plugin or as a dependency of another plugin with CMake, put FindMagnumPlugins.cmake and FindOpenEXR.cmake into your modules/ directory, request the OpenExrImporter component of the MagnumPlugins package in CMake and link to the MagnumPlugins::OpenExrImporter target:

find_package(MagnumPlugins REQUIRED OpenExrImporter)

# ...
target_link_libraries(your-app PRIVATE MagnumPlugins::OpenExrImporter)

See Downloading and building plugins, Plugin usage with CMake, Loading and using plugins and File format support for more information.

Behavior and limitations

Channel mapping

Images containing R, G, B or A channels are imported as PixelFormat::R16F / RG16F / RGB16F / RGBA16F, PixelFormat::R32F / RG32F / RGB32F / RGBA32F or PixelFormat::R32UI / RG32UI / RGB32UI / RGBA32UI, all channels are expected to have the same type.

If neither of the color channels is present and a a Z channel is present instead, the image is imported as PixelFormat::Depth32F, expecting the channel to be of a float type.

If a file doesn't match ither of the above, custom channel mapping can be supplied in the configuration.

Multilayer and multipart images

Images with custom layers (for example with separate channels for a left and right view) can be imported by specifying the layer configuration option.

Multipart images are not supported right now.

Cube map, environment map and deep images

Deep images are not supported right now, cube map and environment map images are currently imported as two-dimensional images without any indication of image type.

Plugin-specific configuration

It's possible to tune various options mainly for channel mapping through configuration(). See below for all options and their default values:

# Import channels of given layer

# Mapping of channel names to output image channels. All channels have to have
# the same type; empty names will cause that channel to not be imported at all,
# leaving the memory zeroed out. See also forceChannelCount.

# If the file doesn't contain any of the channel names specified in r, g, b or
# a, depth is tried instead, in which case it's expected to be a 32-bit float
# and is imported as PixelFormat::Depth32F.

# If any of the channels specified in r, g, b, a don't exist, they will be
# filled with the following values.

# Override channel count for RGBA. Allowed values are 0-4, with zero being the
# default where channel count corresponds to the last name in r, g, b, a that
# exists. So for example if a file has only R and B channels, it's imported as
# RGB with G filled with the gFill value.

Base classes

class AbstractImporter
Base for importer plugins.

Constructors, destructors, conversion operators

OpenExrImporter(PluginManager::AbstractManager& manager, const std::string& plugin) explicit
Plugin manager constructor.