Magnum::Trade::PngImporter class

PNG importer plugin.

Supports Portable Network Graphics (*.png) RGB, RGBA or grayscale images with 8 and 16 bits per channel. Palleted images and images with transparency mask are automatically converted to RGB(A).

This plugin depends on the Trade and libPNG libraries and is built if WITH_PNGIMPORTER is enabled when building Magnum Plugins. To use as a dynamic plugin, you need to load the "PngImporter" plugin from MAGNUM_PLUGINS_IMPORTER_DIR. To use as a static plugin or as a dependency of another plugin with CMake, you need to request the PngImporter component of the MagnumPlugins package and link to the MagnumPlugins::PngImporter target. See Downloading and building plugins, Plugin usage with CMake and Loading and using plugins for more information.

Behavior and limitations

The images are imported with PixelFormat::RGB8Unorm / PixelFormat::RGB16Unorm, PixelFormat::RGBA8Unorm / PixelFormat::RGBA16Unorm or PixelFormat::R8Unorm / PixelFormat::R16Unorm. All imported images use default PixelStorage parameters.

Apple CgBI PNGs

CgBI is a proprietary Apple-specific extension to PNG (details here). Stock libPNG doesn't support these, you might want to use some fork that supports it, for example https://github.com/jongwook/libpng. Or use StbImageImporter, which has the support.

The test for this plugin contains a file that can be used for verifying CgBI support.

Base classes

class AbstractImporter
Base for importer plugins.

Constructors, destructors, conversion operators

PngImporter() explicit
Default constructor.
PngImporter(PluginManager::AbstractManager& manager, const std::string& plugin) explicit
Plugin manager constructor.

Private functions

auto doFeatures() const override -> Features virtual
Implementation for features()
auto doIsOpened() const override -> bool virtual
Implementation for isOpened()
void doClose() override virtual
Implementation for close()
void doOpenData(Containers::ArrayView<const char> data) override virtual
Implementation for openData()
auto doImage2DCount() const override -> UnsignedInt virtual
Implementation for image2DCount()
auto doImage2D(UnsignedInt id) override -> Containers::Optional<ImageData2D> virtual
Implementation for image2D()

Function documentation

UnsignedInt Magnum::Trade::PngImporter::doImage2DCount() const override virtual private

Implementation for image2DCount()

Default implementation returns 0.