This is a snapshot of a work-in-progress documentation theme. If you feel lost, miss something, or want to see the original Doxygen docs instead, head over to the archived version of this documentation page.

Magnum::Trade::StbImageImporter class

Image importer plugin using stb_image.

Supports the following formats:

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

The images are imported with PixelType::UnsignedByte type for all formats except HDR and PixelType::Float for HDR; PixelFormat::RGB, PixelFormat::RGBA, PixelFormat::Red for grayscale or PixelFormat::RG for grayscale + alpha. Grayscale and grayscale + alpha images require extension ARB_texture_rg. Images are imported with default PixelStorage parameters except for alignment, which may be changed to 1 if the data require it.

In OpenGL ES 2.0 if EXT_texture_rg is not supported and in WebGL 1.0, grayscale images use PixelFormat::Luminance instead of PixelFormat::Red and PixelFormat::LuminanceAlpha instead of PixelFormat::RG.

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.