class
PngImporterPNG importer plugin.
Supports Portable Network Graphics (*.png
) grayscale, grayscale+alpha, RGB or RGBA images with 8 and 16 bits per channel. Palleted images and images with transparency mask are automatically converted to G(A) / RGB(A). You can use PngImageConverter to encode images into this format.
Usage
This plugin depends on the Trade and libPNG libraries and is built if MAGNUM_WITH_PNGIMPORTER
is enabled when building Magnum Plugins. To use as a dynamic plugin, load "PngImporter"
via Corrade::
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.
set(MAGNUM_WITH_PNGIMPORTER ON CACHE BOOL "" FORCE) add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL) # So the dynamically loaded plugin gets built implicitly add_dependencies(your-app MagnumPlugins::PngImporter)
To use as a static plugin or as a dependency of another plugin with CMake, put FindMagnumPlugins.cmake into your modules/
directory, request the PngImporter
component of the MagnumPlugins
package and link to the MagnumPlugins::PngImporter
target:
find_package(MagnumPlugins REQUIRED PngImporter) # ... target_link_libraries(your-app PRIVATE MagnumPlugins::PngImporter)
See Downloading and building plugins, Plugin usage with CMake, Loading and using plugins and File format support for more information.
Behavior and limitations
Grayscale images are imported as PixelFormat::
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:/
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 Containers:: StringView& plugin) explicit - Plugin manager constructor.