Skip to content

Commit

Permalink
AnyImageImporter: Delegate .basis files to BasisImporterEtc2
Browse files Browse the repository at this point in the history
Signed-off-by: Squareys <squareys@googlemail.com>
  • Loading branch information
Squareys committed Aug 27, 2019
1 parent aeb3cd4 commit 656a429
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp
Expand Up @@ -57,7 +57,12 @@ void AnyImageImporter::doOpenFile(const std::string& filename) {

/* Detect type from extension */
std::string plugin;
if(Utility::String::endsWith(normalized, ".bmp"))
if(Utility::String::endsWith(normalized, ".basis"))
/* Basis may be transcoded to various target formats.
To ensure consistent output format, it makes sense
to specify it as Etc2 here. */
plugin = "BasisImporterEtc2";
else if(Utility::String::endsWith(normalized, ".bmp"))
plugin = "BmpImporter";
else if(Utility::String::endsWith(normalized, ".dds"))
plugin = "DdsImporter";
Expand Down Expand Up @@ -128,8 +133,11 @@ void AnyImageImporter::doOpenData(Containers::ArrayView<const char> data) {
CORRADE_INTERNAL_ASSERT(manager());

std::string plugin;
/* https://github.com/BinomialLLC/basis_universal/blob/7d784c728844c007d8c95d63231f7adcc0f65364/transcoder/basisu_file_headers.h#L78 */
if(Utility::String::viewBeginsWith(data, "sB\0\x16")
plugin = "BasisImporterEtc2";
/* https://docs.microsoft.com/cs-cz/windows/desktop/direct3ddds/dx-graphics-dds-pguide */
if(Utility::String::viewBeginsWith(data, "DDS "))
else if(Utility::String::viewBeginsWith(data, "DDS "))
plugin = "DdsImporter";
/* http://www.openexr.com/openexrfilelayout.pdf */
else if(Utility::String::viewBeginsWith(data, "\x76\x2f\x31\x01"))
Expand Down
1 change: 1 addition & 0 deletions src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h
Expand Up @@ -66,6 +66,7 @@ of the `Magnum` package and link to the `Magnum::AnyImageImporter` target. See
Supported formats:
- Basis Universal (`*.basis`), loaded with any plugin that provides `BasisImporterEtc2`
- Windows Bitmap (`*.bmp`), loaded with any plugin that provides `BmpImporter`
- DirectDraw Surface (`*.dds` or data with corresponding signature), loaded
with @ref DdsImporter or any other plugin that provides it
Expand Down

0 comments on commit 656a429

Please sign in to comment.