Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
6 changes: 4 additions & 2 deletions src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -128,8 +130,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 = "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 "))
Comment thread
Squareys marked this conversation as resolved.
plugin = "DdsImporter";
/* http://www.openexr.com/openexrfilelayout.pdf */
else if(Utility::String::viewBeginsWith(data, "\x76\x2f\x31\x01"))
Expand Down
2 changes: 2 additions & 0 deletions src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
};

Expand Down
1 change: 1 addition & 0 deletions src/MagnumPlugins/AnyImageImporter/Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ corrade_add_test(AnyImageImporterTest AnyImageImporterTest.cpp
FILES
gray.jpg
image.exr
rgb.basis
rgb.hdr
rgb.png
rgba_dxt1.dds
Expand Down
Binary file added src/MagnumPlugins/AnyImageImporter/Test/rgb.basis
Binary file not shown.