Browse Source

AnyImage{Importer,Converter}: recognize OpenVDB file extension.

Volumetric data. No plugin directly in Magnum at the moment, right now
mainly to support depending projects.
pull/559/head
Vladimír Vondruš 4 years ago
parent
commit
cfd0a1a454
  1. 2
      src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp
  2. 2
      src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h
  3. 1
      src/MagnumPlugins/AnyImageConverter/Test/AnyImageConverterTest.cpp
  4. 2
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp
  5. 1
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h
  6. 3
      src/MagnumPlugins/AnyImageImporter/Test/AnyImageImporterTest.cpp

2
src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp

@ -186,6 +186,8 @@ bool AnyImageConverter::doConvertToFile(const ImageView3D& image, const Containe
plugin = "OpenExrImageConverter"_s; plugin = "OpenExrImageConverter"_s;
else if(normalizedExtension == ".ktx2"_s) else if(normalizedExtension == ".ktx2"_s)
plugin = "KtxImageConverter"_s; plugin = "KtxImageConverter"_s;
else if(normalizedExtension == ".vdb"_s)
plugin = "OpenVdbImageConverter"_s;
else { else {
Error{} << "Trade::AnyImageConverter::convertToFile(): cannot determine the format of" << filename << "for a 3D image"; Error{} << "Trade::AnyImageConverter::convertToFile(): cannot determine the format of" << filename << "for a 3D image";
return false; return false;

2
src/MagnumPlugins/AnyImageConverter/AnyImageConverter.h

@ -76,6 +76,8 @@ tries to convert the file with it. Supported formats for uncompressed data:
- Truevision TGA (`*.tga`, `*.vda`, `*.icb`, `*.vst`), converted with - Truevision TGA (`*.tga`, `*.vda`, `*.icb`, `*.vst`), converted with
@ref TgaImageConverter or any other plugin that provides it. Only @ref TgaImageConverter or any other plugin that provides it. Only
uncompressed 2D images. uncompressed 2D images.
- OpenVDB (`*.vdb`), converted with any plugin that provides
`OpenVdbImageConverter`. Only uncompressed 3D images.
As the converter plugin is picked based on file extension, only saving to files As the converter plugin is picked based on file extension, only saving to files
is supported. is supported.

1
src/MagnumPlugins/AnyImageConverter/Test/AnyImageConverterTest.cpp

@ -171,6 +171,7 @@ constexpr struct {
{"Basis Universal", "file.basis", "BasisImageConverter"}, {"Basis Universal", "file.basis", "BasisImageConverter"},
{"EXR", "file.exr", "OpenExrImageConverter"}, {"EXR", "file.exr", "OpenExrImageConverter"},
{"KTX2", "file.ktx2", "KtxImageConverter"}, {"KTX2", "file.ktx2", "KtxImageConverter"},
{"OpenVDB", "volume.vdb", "OpenVdbImageConverter"},
/* Have at least one test case with uppercase */ /* Have at least one test case with uppercase */
{"EXR uppercase", "FIL~1.EXR", "OpenExrImageConverter"} {"EXR uppercase", "FIL~1.EXR", "OpenExrImageConverter"}
}; };

2
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp

@ -125,6 +125,8 @@ void AnyImageImporter::doOpenFile(const Containers::StringView filename) {
normalizedExtension == ".icb"_s || normalizedExtension == ".icb"_s ||
normalizedExtension == ".vst"_s) normalizedExtension == ".vst"_s)
plugin = "TgaImporter"_s; plugin = "TgaImporter"_s;
else if(normalizedExtension == ".vdb"_s)
plugin = "OpenVdbImporter"_s;
else { else {
Error{} << "Trade::AnyImageImporter::openFile(): cannot determine the format of" << filename; Error{} << "Trade::AnyImageImporter::openFile(): cannot determine the format of" << filename;
return; return;

1
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.h

@ -97,6 +97,7 @@ Supported formats:
- Truevision TGA (`*.tga`, `*.vda`, `*.icb`, `*.vst` or data with - Truevision TGA (`*.tga`, `*.vda`, `*.icb`, `*.vst` or data with
corresponding signature), loaded with @ref TgaImporter or any other plugin corresponding signature), loaded with @ref TgaImporter or any other plugin
that provides it that provides it
- OpenVDB (`*.vdb`), loaded with any plugin that provides `OpenVdbImporter`
Detecting file type through @ref openData() is supported only for a subset of Detecting file type through @ref openData() is supported only for a subset of
formats that are marked as such in the list above. formats that are marked as such in the list above.

3
src/MagnumPlugins/AnyImageImporter/Test/AnyImageImporterTest.cpp

@ -122,7 +122,8 @@ constexpr struct {
{"TIFF", "image.tiff", false, "TiffImporter"}, {"TIFF", "image.tiff", false, "TiffImporter"},
{"TIFF data", "image.tiff", true, "TiffImporter"}, {"TIFF data", "image.tiff", true, "TiffImporter"},
{"Basis", "rgb.basis", false, "BasisImporter"}, {"Basis", "rgb.basis", false, "BasisImporter"},
{"Basis data", "rgb.basis", true, "BasisImporter"} {"Basis data", "rgb.basis", true, "BasisImporter"},
{"OpenVDB", "volume.vdb", false, "OpenVdbImporter"}
/* Not testing everything, just the most important ones */ /* Not testing everything, just the most important ones */
}; };

Loading…
Cancel
Save