Magnum::Trade::AnyImageImporter class

Any image importer plugin.

Detects file type based on file extension or a signature at the start of the file, loads corresponding plugin and then tries to open the file with it. Supported formats:

  • Adaptive Scalable Texture Compression (*.astc or data with corresponding signature), loaded with AstcImporter or any other plugin that provides it
  • Basis Universal (*.basis or data with corresponding signature), loaded with BasisImporter or any other plugin that provides it
  • Windows Bitmap (*.bmp or data with corresponding signature), loaded with any plugin that provides BmpImporter
  • DirectDraw Surface (*.dds or data with corresponding signature), loaded with DdsImporter or any other plugin that provides it
  • Graphics Interchange Format (*.gif), loaded with any plugin that provides GifImporter
  • OpenEXR (*.exr or data with corresponding signature), loaded with OpenExrImporter or any other plugin that provides it
  • Radiance HDR (*.hdr or data with corresponding signature), loaded with any plugin that provides HdrImporter
  • Windows icon/cursor (*.ico, *.cur), loaded with IcoImporter or any other plugin that provides it
  • JPEG (*.jpg, *.jpe, *.jpeg or data with corresponding signature), loaded with JpegImporter or any other plugin that provides it
  • JPEG 2000 (*.jp2), loaded with any plugin that provides Jpeg2000Importer
  • KTX2 (*.ktx2 or data with corresponding signature), loaded with KtxImporter or any other plugin that provides it. If not found, BasisImporter is tried as a fallback.
  • Multiple-image Network Graphics (*.mng), loaded with any plugin that provides MngImporter
  • Portable Bitmap (*.pbm), loaded with any plugin that provides PbmImporter
  • ZSoft PCX (*.pcx), loaded with any plugin that provides PcxImporter
  • Portable Graymap (*.pgm), loaded with any plugin that provides PgmImporter
  • Softimage PIC (*.pic), loaded with any plugin that provides PicImporter
  • Portable Anymap (*.pnm), loaded with any plugin that provides PnmImporter
  • Portable Network Graphics (*.png or data with corresponding signature), loaded with PngImporter or any other plugin that provides it
  • Portable Pixmap (*.ppm), loaded with any plugin that provides PpmImporter
  • Adobe Photoshop (*.psd), loaded with any plugin that provides PsdImporter
  • Silicon Graphics (*.sgi, *.bw, *.rgb, *.rgba), loaded with any plugin that provides SgiImporter
  • Tagged Image File Format (*.tif, *.tiff or data with corresponding signature), loaded with any plugin that provides TiffImporter
  • Truevision TGA (*.tga, *.vda, *.icb, *.vst or data with corresponding signature), loaded with TgaImporter or any other plugin that provides it
  • OpenVDB (*.vdb), loaded with any plugin that provides OpenVdbImporter
  • WebP (*.webp or data with corresponding signature), loaded with WebPImporter or any other plugin that provides it

Detecting file type through openData() is supported only for a subset of formats that are marked as such in the list above. ImporterFeature::FileCallback is supported as well.

Usage

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

Additionally, if you're using Magnum as a CMake subproject, do the following:

set(MAGNUM_WITH_ANYIMAGEIMPORTER ON CACHE BOOL "" FORCE)
add_subdirectory(magnum EXCLUDE_FROM_ALL)

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

To use as a static plugin or as a dependency of another plugin with CMake, you need to request the AnyImageImporter component of the Magnum package and link to the Magnum::AnyImageImporter target:

find_package(Magnum REQUIRED AnyImageImporter)

# ...
target_link_libraries(your-app PRIVATE Magnum::AnyImageImporter)

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

Interface proxying and option propagation

On a call to openFile() / openData(), a file format is detected from the extension / file signature and a corresponding plugin is loaded. After that, flags set via setFlags(), file callbacks set via setFileCallback() and options set through configuration() are propagated to the concrete implementation. A warning is emitted in case an option set is not present in the default configuration of the target plugin.

Calls to the image1DCount() / image2DCount() / image3DCount(), image1DLevelCount() / image2DLevelCount() / image3DLevelCount() and image1D() / image2D() / image3D() functions are then proxied to the concrete implementation. The close() function closes and discards the internally instantiated plugin; isOpened() works as usual.

Besides delegating the flags, the AnyImageImporter itself recognizes ImporterFlag::Verbose, printing info about the concrete plugin being used when the flag is enabled. ImporterFlag::Quiet is recognized as well and causes all warnings to be suppressed.

Base classes

class AbstractImporter
Base for importer plugins.

Constructors, destructors, conversion operators

AnyImageImporter(PluginManager::Manager<AbstractImporter>& manager) explicit
Constructor with access to plugin manager.
AnyImageImporter(PluginManager::AbstractManager& manager, const Containers::StringView& plugin) explicit
Plugin manager constructor.
AnyImageImporter(const AnyImageImporter&) deleted
Copying is not allowed.
AnyImageImporter(AnyImageImporter&&) noexcept
Move constructor.

Public functions

auto operator=(const AnyImageImporter&) -> AnyImageImporter& deleted
Copying is not allowed.
auto operator=(AnyImageImporter&&) -> AnyImageImporter& deleted
Only move construction is allowed.

Function documentation

Magnum::Trade::AnyImageImporter::AnyImageImporter(AnyImageImporter&&) noexcept

Move constructor.

See Corrade::PluginManager::AbstractPlugin::AbstractPlugin(AbstractPlugin&&) for caveats.