Magnum::TextureTools namespace

Texture tools.

Contents

Tools for generating, compressing and optimizing textures.

This library is built if WITH_TEXTURETOOLS is enabled when building Magnum. To use this library with CMake, you need to request the TextureTools component of the Magnum package in CMake and link to the Magnum::TextureTools target:

find_package(Magnum REQUIRED TextureTools)

# ...
target_link_libraries(your-app Magnum::TextureTools)

Note that functionality depending on GL APIs is available only if Magnum is built with both WITH_GL and TARGET_GL enabled (which is done by default).

Additional utilities are built separately. See the magnum-distancefieldconverter utility documentation, Downloading and building and Usage with CMake for more information.

Classes

class DistanceField
Create a signed distance field.

Functions

auto atlas(const Vector2i& atlasSize, const std::vector<Vector2i>& sizes, const Vector2i& padding = Vector2i()) -> std::vector<Range2Di>
Pack textures into texture atlas.
auto convert(const ImageView2D& input, PixelFormat format) -> Image2D
Convert an image to a different pixel format.
void distanceField(GL::Texture2D& input, GL::Texture2D& output, const Range2Di& rectangle, Int radius, const Vector2i& imageSize = Vector2i{}) deprecated in 2019.01
Create a signed distance field.

Function documentation

std::vector<Range2Di> Magnum::TextureTools::atlas(const Vector2i& atlasSize, const std::vector<Vector2i>& sizes, const Vector2i& padding = Vector2i())

Pack textures into texture atlas.

Parameters
atlasSize Size of resulting atlas
sizes Sizes of all textures in the atlas
padding Padding around each texture

Packs many small textures into one larger. If the textures cannot be packed into required size, empty vector is returned.

Padding is added twice to each size and the atlas is laid out so the padding don't overlap. Returned sizes are the same as original sizes, i.e. without the padding.

Image2D Magnum::TextureTools::convert(const ImageView2D& input, PixelFormat format)

Convert an image to a different pixel format.

Parameters
input Input image
format Desired format

Currently, only reducing or expanding channel count is supported — for example, converting a PixelFormat::RGBA8Unorm image to PixelFormat::RGB8Unorm, or PixelFormat::R8Unorm to PixelFormat::RGBA8Unorm. Channels missing in the original image are set to 0 for RGB channels and 1.0 (or a packed equivalent) for the alpha channel.

void Magnum::TextureTools::distanceField(GL::Texture2D& input, GL::Texture2D& output, const Range2Di& rectangle, Int radius, const Vector2i& imageSize = Vector2i{})

Create a signed distance field.