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

Image resizing using stb_image_resize.

Performs downsampling and upsampling of 8-bit, 16-bit and float 2D and 2D array or cube images using the stb_image_resize library.

Usage

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

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

set(MAGNUM_WITH_STBRESIZEIMAGECONVERTER ON CACHE BOOL "" FORCE)
add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL)

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

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

find_package(MagnumPlugins REQUIRED StbResizeImageConverter)

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

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

Behavior and limitations

Accepts PixelFormat::RGBA8Unorm, RGBA8Srgb, RGBA16Unorm, RGBA16F, RGBA32F and their 1-, 2- and 3-component variants. In order to perform a conversion, you have to set the size configuration option.

Image flags are passed through unchanged. As the resizing operation operates in two dimensions, the size option always takes a 2D size. 1D images and 1D array images (with ImageFlag2D::Array set) are not supported, 3D images are expected to have either ImageFlag3D::Array nor ImageFlag3D::CubeMap set.

Plugin-specific configuration

Apart from the mandatory size, other options can be set through configuration(). See below for all options and their default values:

[configuration]
# Target width and height, separated by a space. Required.
size=
# By default, if the image is smaller than the provided size, it's upsampled.
# Disable this option to keep smaller sizes as-is. The target size will be a
# minimum of image size and target size in both dimensions, if the image is
# smaller than target size in both dimensions the data will be copied
# unchanged.
upsample=true

# How neighboring pixel values are retrieved on image edges. Valid values
# are:
#  - clamp -- as if the edge pixels were extended
#  - wrap -- as if the image was repeated
#  - reflect -- as if the image was repeated and reflected
#  - zero -- uses zero values for out-of-bounds pixels
edge=clamp

# Sampling filter. Valid values are:
#  - box -- a trapezoid w/1-pixel wide ramps, same result as box for integer
#    scale ratios
#  - triangle -- on upsampling, produces same results as bilinear texture
#    filtering
#  - cubicspline -- the cubic b-spline (aka Mitchell-Netrevalli with
#    B=1,C=0), gaussian-esque
#  - catmullrom -- an interpolating cubic spline
#  - mitchell -- Mitchell-Netrevalli filter with B=1/3, C=1/3
#  - point -- nearest-neighbor
# If empty, the default is catmullrom for upsampling and mitchell for
# downsampling.
filter=

# Treat alpha as premultiplied. Image editors usually don't export
# premultiplied alpha, so it's off by default.
alphaPremultiplied=false
# If the input format is sRGB, alpha is usually encoded as linear. Enable in
# the unlikely case when alpha is sRGB-encoded as well.
alphaUsesSrgb=false

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

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