Browse Source

AnyImageConverter: lowercase() filename before recognizing suffix

pull/312/head
Max Schwarz 7 years ago
parent
commit
1a6d0b1d52
  1. 24
      src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp

24
src/MagnumPlugins/AnyImageConverter/AnyImageConverter.cpp

@ -46,24 +46,26 @@ auto AnyImageConverter::doFeatures() const -> Features {
bool AnyImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) { bool AnyImageConverter::doExportToFile(const ImageView2D& image, const std::string& filename) {
CORRADE_INTERNAL_ASSERT(manager()); CORRADE_INTERNAL_ASSERT(manager());
std::string normalized = Utility::String::lowercase(filename);
/* Detect type from extension */ /* Detect type from extension */
std::string plugin; std::string plugin;
if(Utility::String::endsWith(filename, ".bmp")) if(Utility::String::endsWith(normalized, ".bmp"))
plugin = "BmpImageConverter"; plugin = "BmpImageConverter";
else if(Utility::String::endsWith(filename, ".exr")) else if(Utility::String::endsWith(normalized, ".exr"))
plugin = "OpenExrImageConverter"; plugin = "OpenExrImageConverter";
else if(Utility::String::endsWith(filename, ".hdr")) else if(Utility::String::endsWith(normalized, ".hdr"))
plugin = "HdrImageConverter"; plugin = "HdrImageConverter";
else if(Utility::String::endsWith(filename, ".jpg") || else if(Utility::String::endsWith(normalized, ".jpg") ||
Utility::String::endsWith(filename, ".jpeg") || Utility::String::endsWith(normalized, ".jpeg") ||
Utility::String::endsWith(filename, ".jpe")) Utility::String::endsWith(normalized, ".jpe"))
plugin = "JpegImageConverter"; plugin = "JpegImageConverter";
else if(Utility::String::endsWith(filename, ".png")) else if(Utility::String::endsWith(normalized, ".png"))
plugin = "PngImageConverter"; plugin = "PngImageConverter";
else if(Utility::String::endsWith(filename, ".tga") || else if(Utility::String::endsWith(normalized, ".tga") ||
Utility::String::endsWith(filename, ".vda") || Utility::String::endsWith(normalized, ".vda") ||
Utility::String::endsWith(filename, ".icb") || Utility::String::endsWith(normalized, ".icb") ||
Utility::String::endsWith(filename, ".vst")) Utility::String::endsWith(normalized, ".vst"))
plugin = "TgaImageConverter"; plugin = "TgaImageConverter";
else { else {
Error() << "Trade::AnyImageConverter::exportToFile(): cannot determine type of file" << filename; Error() << "Trade::AnyImageConverter::exportToFile(): cannot determine type of file" << filename;

Loading…
Cancel
Save