Magnum::Trade::TgaImageConverter class

TGA image converter plugin.

Creates Truevision TGA (*.tga) files from images with format PixelFormat::RGB8Unorm, PixelFormat::RGBA8Unorm or PixelFormat::R8Unorm.

Usage

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

Additionally, if you're using Magnum as a CMake subproject, do the following:

set(MAGNUM_WITH_TGAIMAGECONVERTER ON CACHE BOOL "" FORCE)
add_subdirectory(magnum EXCLUDE_FROM_ALL)

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

To use as a static plugin or as a dependency of another plugin with CMake, you need to request the TgaImageConverter component of the Magnum package and link to the Magnum::TgaImageConverter target:

find_package(Magnum REQUIRED TgaImageConverter)

# ...
target_link_libraries(your-app PRIVATE Magnum::TgaImageConverter)

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

Behavior and limitations

The output is RLE-compressed by default unless the uncompressed output is smaller than RLE. You can always produce uncompressed files by disabling the rle configuration option, and always RLE files by disabling the rleFallbackIfLarger option. Enabling rleAcrossScanlines can result in even smaller files but such files are considered invalid in the TGA 2.0 spec and thus may cause issues in certain importers.

The TGA file format doesn't have a way to distinguish between 2D and 1D array images. If an image has ImageFlag2D::Array set, a warning is printed and the file is saved as a regular 2D image.

While TGA files can have several extensions, extension() always returns "tga" as that's the most common one. As TGA doesn't have a registered MIME type, mimeType() returns "image/x-tga".

The converter recognizes ImageConverterFlag::Verbose, printing additional info when the flag is enabled. ImageConverterFlag::Quiet is recognized as well and causes all conversion warnings to be suppressed.

Plugin-specific configuration

It's possible to tune various output options through configuration(). See below for all options and their default values:

# Run-length encode the data for smaller file size
rle=true

# Fall back to uncompressed output if the RLE output is larger. Disable to
# always produce a RLE output.
rleFallbackIfLarger=true

# Allow RLE to go across scanlines. Can result in even smaller files but
# considered invalid in the TGA 2.0 specification and thus may cause issues
# in certain importers.
rleAcrossScanlines=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

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