Magnum::Trade::StbDxtImageConverter class new in Git master

BC1/BC3 compressor using stb_dxt.

Converts uncompressed RGBA images to block-compressed BC1/BC3 images using the stb_dxt library.


This plugin depends on the Trade library and is built if WITH_STBDXTIMAGECONVERTER is enabled when building Magnum Plugins. To use as a dynamic plugin, load "StbDxtImageConverter" via Corrade::PluginManager::Manager.

Additionally, if you're using Magnum as a CMake subproject, bundle the magnum-plugins repository and do the following:

add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL)

# So the dynamically loaded plugin gets built implicitly
add_dependencies(your-app MagnumPlugins::StbDxtImageConverter)

To use as a static plugin or as a dependency of another plugin with CMake, put FindMagnumPlugins.cmake into your modules/ directory, request the StbDxtImageConverter component of the MagnumPlugins package and link to the MagnumPlugins::StbDxtImageConverter target:

find_package(MagnumPlugins REQUIRED StbDxtImageConverter)

# ...
target_link_libraries(your-app PRIVATE MagnumPlugins::StbDxtImageConverter)

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

Behavior and limitations

Currently, only PixelFormat::RGBA8Unorm / RGBA8Srgb is accepted, producing a compressed ImageData2D with CompressedPixelFormat::Bc3RGBAUnorm / Bc3RGBASrgb. If the alpha configuration option is disabled, an image with CompressedPixelFormat::Bc1RGBUnorm / Bc1RGBSrgb is returned instead.

The input image size is expected to be divisible by four in both dimensions. If your image doesn't fit this requirement, you have to pad/crop or resample it first.

Unlike image converters dealing with uncompressed pixel formats, the image isn't Y-flipped on export due to the nontrivial amount of work involved with Y-flipping block-compressed data. This is in line with importers of compressed pixel formats such as DdsImporter, which don't Y-flip compressed formats on import either.

Plugin-specific configuration

Various compressor options can be set through configuration(). See below for all options and their default values:

# Store the alpha channel. If enabled, the output format is BC3 (128 bits per
# block), if disabled the format is BC1 (64 bits per block).

# High-quality mode, does two refinement steps instead of one. ~30–40% slower.

See Editing plugin-specific configuration for more information and an example showing how to edit the configuration values.

Base classes

class AbstractImageConverter
Base for image converter plugins.

Constructors, destructors, conversion operators

StbDxtImageConverter(PluginManager::AbstractManager& manager, const Containers::StringView& plugin) explicit
Plugin manager constructor.