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.

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.

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

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.

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 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

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

Implementation for image2DCount()

Default implementation returns 0.