Magnum::Trade::PngImageConverter class

PNG image converter plugin.

Creates Portable Network Graphics (*.png) files using the libPNG library. You can use PngImporter to import images in this format.


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

Additionally, if you're using Magnum as a CMake subproject, bundle the magnum-plugins repository and do the following. Using libPNG itself as a CMake subproject isn't tested at the moment, so you need to provide it as a system dependency and point CMAKE_PREFIX_PATH to its installation dir if necessary.

add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL)

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

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

find_package(MagnumPlugins REQUIRED PngImageConverter)

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

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

Behavior and limitations

Accepts 2D images in PixelFormat::R8Unorm / PixelFormat::R16Unorm, PixelFormat::RG8Unorm / PixelFormat::RG16Unorm, PixelFormat::RGB8Unorm / PixelFormat::RGB16Unorm or PixelFormat::RGBA8Unorm / PixelFormat::RGBA16Unorm.

The PNG 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.

The plugin recognizes ImageConverterFlag::Quiet, which will cause all conversion warnings, coming either from the plugin or libpng itself, to be suppressed.

Base classes

class AbstractImageConverter
Base for image converter plugins.

Constructors, destructors, conversion operators

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