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::AbstractImageConverter class

Base for image converter plugins.

Provides functionality for converting images between various internal formats or compressing them. See Loading and using plugins for more information and *ImageConverter classes in Trade namespace for available image converter plugins.

Subclassing

The plugin needs to implement thedoFeatures() function and one or more of doExportToImage(), doExportToCompressedImage(), doExportToData() or doExportToFile() functions based on what features are supported.

You don't need to do most of the redundant sanity checks, these things are checked by the implementation:

Plugin interface string is "cz.mosra.magnum.Trade.AbstractImageConverter/0.2.1".

Derived classes

class AnyImageConverter
Any image converter plugin.
class MiniExrImageConverter
OpenEXR image converter plugin using miniexr.
class PngImageConverter
PNG image converter plugin.
class StbImageConverter
Image converter plugin using stb_image_write.
class TgaImageConverter
TGA image converter plugin.

Public types

enum class Feature: UnsignedByte { ConvertImage = 1 << 0, ConvertCompressedImage = 1 << 1, ConvertFile = 1 << 2, ConvertCompressedFile = 1 << 3, ConvertData = ConvertFile|(1 << 4), ConvertCompressedData = ConvertCompressedFile|(1 << 4) }
Features supported by this converter.
using Features = Containers::EnumSet<Feature>
Features supported by this converter.

Constructors, destructors, conversion operators

AbstractImageConverter() explicit
Default constructor.
AbstractImageConverter(PluginManager::Manager<AbstractImageConverter>& manager) explicit
Constructor with access to plugin manager.
AbstractImageConverter(PluginManager::AbstractManager& manager, const std::string& plugin) explicit
Plugin manager constructor.

Public functions

auto features() const -> Features
Features supported by this converter.
auto exportToImage(const ImageView2D& image) -> Containers::Optional<Image2D>
Convert image to different format.
auto exportToCompressedImage(const ImageView2D& image) -> Containers::Optional<CompressedImage2D>
Convert image to compressed format.
auto exportToData(const ImageView2D& image) -> Containers::Array<char>
Export image to raw data.
auto exportToData(const CompressedImageView2D& image) -> Containers::Array<char>
Export compressed image to raw data.
auto exportToData(const ImageData2D& image) -> Containers::Array<char>
Export image to raw data.
auto exportToFile(const ImageView2D& image, const std::string& filename) -> bool
Export image to file.
auto exportToFile(const CompressedImageView2D& image, const std::string& filename) -> bool
Export compressed image to file.
auto exportToFile(const ImageData2D& image, const std::string& filename) -> bool
Export image to file.

Protected functions

auto doFeatures() const -> Features pure virtual
Implementation of features()
auto doExportToImage(const ImageView2D& image) -> Containers::Optional<Image2D> virtual
Implementation of exportToImage()
auto doExportToCompressedImage(const ImageView2D& image) -> Containers::Optional<CompressedImage2D> virtual
Implementation of exportToCompressedImage()
auto doExportToData(const ImageView2D& image) -> Containers::Array<char> virtual
Implementation of exportToData(const ImageView2D&)
auto doExportToData(const CompressedImageView2D& image) -> Containers::Array<char> virtual
Implementation of exportToData(const CompressedImageView2D&)
auto doExportToFile(const ImageView2D& image, const std::string& filename) -> bool virtual
Implementation of exportToFile(const ImageView2D&, const std::string&)
auto doExportToFile(const CompressedImageView2D& image, const std::string& filename) -> bool virtual
Implementation of exportToFile(const CompressedImageView2D&, const std::string&)

Enum documentation

enum class Magnum::Trade::AbstractImageConverter::Feature: UnsignedByte

Features supported by this converter.

Enumerators
ConvertImage

Conversion to image with different format with exportToImage()

ConvertCompressedImage

Conversion to compressed image with exportToCompressedImage()

ConvertFile

Exporting to file with exportToFile(const ImageView2D&, const std::string&)

ConvertCompressedFile

Exporting to file with exportToFile(const CompressedImageView2D&, const std::string&)

ConvertData

Exporting to raw data with exportToData(const ImageView2D&). Implies Feature::ConvertFile.

ConvertCompressedData

Exporting compressed image to raw data with exportToData(const CompressedImageView2D&). Implies Feature::ConvertCompressedFile.

Typedef documentation

typedef Containers::EnumSet<Feature> Magnum::Trade::AbstractImageConverter::Features

Features supported by this converter.

Function documentation

Containers::Optional<Image2D> Magnum::Trade::AbstractImageConverter::exportToImage(const ImageView2D& image)

Convert image to different format.

Available only if Feature::ConvertImage is supported. Returns converted image on success, Containers::NullOpt otherwise.

Containers::Optional<CompressedImage2D> Magnum::Trade::AbstractImageConverter::exportToCompressedImage(const ImageView2D& image)

Convert image to compressed format.

Available only if Feature::ConvertCompressedImage is supported. Returns converted image on success, Containers::NullOpt otherwise.

Containers::Array<char> Magnum::Trade::AbstractImageConverter::exportToData(const ImageView2D& image)

Export image to raw data.

Available only if Feature::ConvertData is supported. Returns data on success, zero-sized array otherwise.

Containers::Array<char> Magnum::Trade::AbstractImageConverter::exportToData(const CompressedImageView2D& image)

Export compressed image to raw data.

Available only if Feature::ConvertCompressedData is supported. Returns data on success, zero-sized array otherwise.

Containers::Array<char> Magnum::Trade::AbstractImageConverter::exportToData(const ImageData2D& image)

Export image to raw data.

Based on whether the image is compressed or not, calls either exportToData(const ImageView2D&) or exportToData(const CompressedImageView2D&). See documentation of those two functions for details.

bool Magnum::Trade::AbstractImageConverter::exportToFile(const ImageView2D& image, const std::string& filename)

Export image to file.

Available only if Feature::ConvertFile or Feature::ConvertData is supported. Returns true on success, false otherwise.

bool Magnum::Trade::AbstractImageConverter::exportToFile(const CompressedImageView2D& image, const std::string& filename)

Export compressed image to file.

Available only if Feature::ConvertCompressedFile or Feature::ConvertCompressedData is supported. Returns true on success, false otherwise.

bool Magnum::Trade::AbstractImageConverter::exportToFile(const ImageData2D& image, const std::string& filename)

Export image to file.

Based on whether the image is compressed or not, calls either exportToFile(const ImageView2D&, const std::string&) or exportToFile(const CompressedImageView2D&, const std::string&). See documentation of those two functions for details.

bool Magnum::Trade::AbstractImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) virtual protected

Implementation of exportToFile(const ImageView2D&, const std::string&)

If Feature::ConvertData is supported, default implementation calls doExportToData(const ImageView2D&) and saves the result to given file.

bool Magnum::Trade::AbstractImageConverter::doExportToFile(const CompressedImageView2D& image, const std::string& filename) virtual protected

Implementation of exportToFile(const CompressedImageView2D&, const std::string&)

If Feature::ConvertCompressedData is supported, default implementation calls doExportToData(const CompressedImageView2D&) and saves the result to given file.