Magnum::Trade::AnyImageImporter class

Any image importer plugin.

Detects file type based on file extension, loads corresponding plugin and then tries to open the file with it. Supported formats:

  • 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 any plugin that provides OpenExrImporter
  • 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 any plugin that provides KtxImporter
  • 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

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

Usage

This plugin depends on the Trade library and is built if 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(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() and options set through configuration() are propagated to the concrete implementation, with a warning emitted in case given option 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.

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 std::string& 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.