Magnum::Trade::StbImageImporter class

Image importer plugin using stb_image.

Supports the following formats using the stb_image library:

  • Windows Bitmap (*.bmp), only non-1bpp, no RLE
  • Graphics Interchange Format (*.gif)
  • Radiance HDR (*.hdr)
  • JPEG (*.jpg, *.jpe, *.jpeg), except for arithmetic encoding
  • Portable Graymap (*.pgm)
  • Softimage PIC (*.pic)
  • Portable Network Graphics (*.png)
  • Portable Pixmap (*.ppm)
  • Adobe Photoshop (*.psd), only composited view
  • Truevision TGA (*.tga, *.vda, *.icb, *.vst)

Creates RGB, RGBA, grayscale or grayscale + alpha images with 8 bits per channel. Palleted images are automatically converted to RGB(A).

This plugin depends on the Trade library and is built if WITH_STBIMAGEIMPORTER is enabled when building Magnum Plugins. To use as a dynamic plugin, you need to load the "StbImageImporter" 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 StbImageImporter component of the MagnumPlugins package and link to the MagnumPlugins::StbImageImporter target. See Downloading and building plugins, Plugin usage with CMake and Loading and using plugins for more information.

This plugins provides BmpImporter, GifImporter, HdrImporter, JpegImporter, PgmImporter, PicImporter, PngImporter, PpmImporter, PsdImporter and TgaImporter plugins, but note that this plugin doesn't have complete support for all format quirks and the performance might be worse than when using plugin dedicated for given format.

Behavior and limitations

The images are imported with PixelFormat::RGB8Unorm, PixelFormat::RGBA8Unorm, PixelFormat::R8Unorm for grayscale or PixelFormat::RG8Unorm for grayscale + alpha for all format except HDR, HDR images are imported with PixelFormat::RGB32F, PixelFormat::RGBA32F, PixelFormat::R32F or PixelFormat::RG32F. Images are imported with default PixelStorage parameters except for alignment, which may be changed to 1 if the data require it.

Apple CgBI PNGs

CgBI is a proprietary Apple-specific extension to PNG (details here). The importer detects those files and converts BGRA channels back to RGBA.

Base classes

class AbstractImporter
Base for importer plugins.

Constructors, destructors, conversion operators

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