diff --git a/src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp b/src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp index bdb165f667..638bd38d75 100644 --- a/src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp +++ b/src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp @@ -54,6 +54,8 @@ bool AnyImageConverter::doExportToFile(const ImageView2D& image, const std::stri std::string plugin; if(Utility::String::endsWith(normalized, ".bmp")) plugin = "BmpImageConverter"; + else if(Utility::String::endsWith(normalized, ".basis")) + plugin = "BasisImageConverter"; else if(Utility::String::endsWith(normalized, ".exr")) plugin = "OpenExrImageConverter"; else if(Utility::String::endsWith(normalized, ".hdr")) diff --git a/src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h b/src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h index a8d53f81a5..507d37be05 100644 --- a/src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h +++ b/src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h @@ -66,10 +66,12 @@ target. See @ref building, @ref cmake and @ref plugins for more information. Supported formats for uncompressed data: -- OpenEXR (`*.exr`), converted with any plugin that provides - `OpenExrImageConverter` +- Basis Universal (`*.basis`), converted with @ref BasisImageConverter or any other + plugin that provides it - Windows Bitmap (`*.bmp`), converted with any plugin that provides `BmpImageConverter` +- OpenEXR (`*.exr`), converted with any plugin that provides + `OpenExrImageConverter` - Radiance HDR (`*.hdr`), converted with any plugin that provides `HdrImageConverter` - JPEG (`*.jpg`, `*.jpe`, `*.jpeg`), converted with @ref JpegImageConverter diff --git a/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp b/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp index 797463fbca..b147ce14aa 100644 --- a/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp +++ b/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp @@ -57,7 +57,9 @@ 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")) + plugin = "BasisImporter"; + else if(Utility::String::endsWith(normalized, ".bmp")) plugin = "BmpImporter"; else if(Utility::String::endsWith(normalized, ".dds")) plugin = "DdsImporter"; @@ -128,8 +130,11 @@ void AnyImageImporter::doOpenData(Containers::ArrayView 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 = "BasisImporter"; /* 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")) diff --git a/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h b/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h index 403228edc0..5d5ba9a74f 100644 --- a/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h +++ b/src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h @@ -66,6 +66,8 @@ of the `Magnum` package and link to the `Magnum::AnyImageImporter` target. See Supported formats: +- Basis Universal (`*.basis`), loaded @ref BasisImporter or any other plugin + that provides it - 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 diff --git a/src/MagnumPlugins/AnyImageImporter/Test/AnyImageImporterTest.cpp b/src/MagnumPlugins/AnyImageImporter/Test/AnyImageImporterTest.cpp index ff463ef2cd..ff73e427ba 100644 --- a/src/MagnumPlugins/AnyImageImporter/Test/AnyImageImporterTest.cpp +++ b/src/MagnumPlugins/AnyImageImporter/Test/AnyImageImporterTest.cpp @@ -87,7 +87,8 @@ constexpr struct { {"BMP", "image.bmp", nullptr, "BmpImporter"}, {"GIF", "image.gif", nullptr, "GifImporter"}, {"PSD", "image.psd", nullptr, "PsdImporter"}, - {"TIFF", "image.tiff", nullptr, "TiffImporter"} + {"TIFF", "image.tiff", nullptr, "TiffImporter"}, + {"Basis", "rgb.basis", nullptr, "BasisImporter"} /* Not testing everything, just the most important ones */ }; diff --git a/src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt b/src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt index a338071e7b..2c4f57014d 100644 --- a/src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt @@ -56,6 +56,7 @@ corrade_add_test(AnyImageImporterTest AnyImageImporterTest.cpp FILES gray.jpg image.exr + rgb.basis rgb.hdr rgb.png rgba_dxt1.dds diff --git a/src/MagnumPlugins/AnyImageImporter/Test/rgb.basis b/src/MagnumPlugins/AnyImageImporter/Test/rgb.basis new file mode 100644 index 0000000000..49f3cdbee5 Binary files /dev/null and b/src/MagnumPlugins/AnyImageImporter/Test/rgb.basis differ