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.

This plugin depends on the Trade library and is built if WITH_ANYIMAGEIMPORTER is enabled when building Magnum. To use as a dynamic plugin, you need to load the "AnyImageImporter" plugin from MAGNUM_PLUGINS_IMPORTER_DIR. 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. See Downloading and building, Usage with CMake and Loading and using plugins for more information.

Supported formats:

  • Windows Bitmap (*.bmp), 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
  • 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
  • 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), 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.

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.

Private functions

auto doFeatures() const override -> Features virtual
Implementation for features()
auto doIsOpened() const override -> bool virtual
Implementation for isOpened()
void doClose() override virtual
Implementation for close()
void doOpenFile(const std::string& filename) override virtual
Implementation for openFile()
void doOpenData(Containers::ArrayView<const char> data) override virtual
Implementation for openData()
auto doImage2DCount() const override -> UnsignedInt virtual
Implementation for image2DCount()
auto doImage2D(UnsignedInt id) override -> Containers::Optional<ImageData2D> virtual
Implementation for image2D()

Function documentation

void Magnum::Trade::AnyImageImporter::doOpenFile(const std::string& filename) override virtual private

Implementation for openFile()

If Feature::OpenData is supported, default implementation opens the file and calls doOpenData() with its contents. It is allowed to call this function from your doOpenFile() implementation — in particular, this implementation will also correctly handle callbacks set through setFileCallback().

This function is not called when file callbacks are set through setFileCallback() and Feature::FileCallback is not supported — instead, file is loaded though the callback and data passed through to doOpenData().

UnsignedInt Magnum::Trade::AnyImageImporter::doImage2DCount() const override virtual private

Implementation for image2DCount()

Default implementation returns 0.