Magnum::Trade::StbImageConverter class

Image converter plugin using stb_image_write.

Creates files in one of the following formats using the stb_image_write library:

If the conversion results in lost channels (such as saving RGBA to a JPEG, losing the alpha in process), a warning is printed to the output.

This plugin depends on the Trade library and is built if WITH_STBIMAGECONVERTER is enabled when building Magnum Plugins. To use as a dynamic plugin, you need to load one of the "StbBmpImageConverter", "StbHdrImageConverter", "StbPngImageConverter", "StbTgaImageConverter" plugins from MAGNUM_PLUGINS_IMAGECONVERTER_DIR. If you would load the plugin as just "StbImageConverter", it won't be able to guess the desired output format. To use as a static plugin or as a dependency of another plugin with CMake, you need to request the StbImageConverter component of the MagnumPlugins package and link to the MagnumPlugins::StbImageConverter target. See Downloading and building plugins, Plugin usage with CMake and Loading and using plugins for more information.

Besides StbBmpImageConverter, StbHdrImageConverter, StbJpegImageConverter, StbPngImageConverter and StbTgaImageConverter aliases this plugin provides also BmpImageConverter, HdrImageConverter, JpegImageConverter, PngImageConverter and TgaImageConverter plugins, but note that this plugin may generate slightly larger files and the performance might be worse than when using plugins dedicated for given format.

Plugin-specific configuration

For some formats, it's possible to tune various output options through configuration(). See below for all options and their default values:

[configuration]

# Compression quality for JPEG output (0 - 1, 1 is the best). Corresponds to
# the same option in JpegImageConverter.
jpegQuality=0.8

Base classes

class AbstractImageConverter
Base for image converter plugins.

Public types

enum class Format: Int { Bmp = 1, Jpeg, Hdr, Png, Tga }
Output file format.

Constructors, destructors, conversion operators

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

Private functions

auto doFeatures() const override -> Features virtual
Implementation of features()
auto doExportToData(const ImageView2D& image) override -> Containers::Array<char> virtual
Implementation of exportToData(const ImageView2D&)

Enum documentation

enum class Magnum::Trade::StbImageConverter::Format: Int

Output file format.

Enumerators
Bmp

Output BMP images

Jpeg

Output JPEG images

Hdr

Output HDR images

Png

Output PNG images

Tga

Output TGA images

Function documentation

Magnum::Trade::StbImageConverter::StbImageConverter(Format format) explicit

Default constructor.

The converter outputs files in format defined by Format.

Magnum::Trade::StbImageConverter::StbImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin) explicit

Plugin manager constructor.

Outputs files in format based on which alias was used to load the plugin.