class new in Git masterSpngImporter
PNG importer plugin using libspng.
Imports Portable Network Graphics (
*.png) images using the libspng library. Supports grayscale, grayscale+alpha, RGB and RGBA images with 1, 2, 4, 8 and 16 bits per channel. Palleted images and images with transparency mask are automatically converted to G(A) / RGB(A).
This plugin provides the
PngImporter plugin and can be considerably faster than PngImporter, especially when combined with zlib-ng.
This plugin depends on the Trade library and is built if
MAGNUM_WITH_SPNGIMPORTER is enabled when building Magnum Plugins. To use as a dynamic plugin, load
"SpngImporter" via Corrade::
Additionally, if you're using Magnum as a CMake subproject, bundle the magnum-plugins repository and do the following. Using libspng 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_SPNGIMPORTER ON CACHE BOOL "" FORCE) add_subdirectory(magnum-plugins EXCLUDE_FROM_ALL) # So the dynamically loaded plugin gets built implicitly add_dependencies(your-app MagnumPlugins::SpngImporter)
To use as a static plugin or as a dependency of another plugin with CMake, put FindMagnumPlugins.cmake and FindSpng.cmake into your
modules/ directory, request the
SpngImporter component of the
MagnumPlugins package in CMake and link to the
find_package(MagnumPlugins REQUIRED SpngImporter) # ... target_link_libraries(your-app PRIVATE MagnumPlugins::SpngImporter)
See Downloading and building plugins, Plugin usage with CMake, Loading and using plugins and File format support for more information.
Behavior and limitations
The supported format feature set is similar to PngImporter — grayscale images are imported as PixelFormat::
The only exception is grayscale + alpha, which is improted as PixelFormat::
Handling of incomplete and corrupted data
In order to support Y flipping and row alignment, the importer uses libspng's progressive decoding which doesn't report errors in case of truncated files or invalid data chunks. Import of such files will succeed, but the contents will be incomplete. See libpng documentation about error handling for more information.
Apple CgBI PNGs
CgBI is a proprietary Apple-specific extension to PNG (details here), unfortunately libspng doesn't plan to support it. To import such files use either StbImageImporter or PngImporter with a patched libpng.
- class AbstractImporter
- Base for importer plugins.
Constructors, destructors, conversion operators
AbstractManager& manager, const Containers:: StringView& plugin) explicit
- Plugin manager constructor.