Browse Source

AnyImageImporter: lowercase() filename before recognizing suffix

pull/312/head
Max Schwarz 7 years ago
parent
commit
5af223a79f
  1. 58
      src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp

58
src/MagnumPlugins/AnyImageImporter/AnyImageImporter.cpp

@ -51,54 +51,56 @@ void AnyImageImporter::doClose() {
void AnyImageImporter::doOpenFile(const std::string& filename) { void AnyImageImporter::doOpenFile(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 = "BmpImporter"; plugin = "BmpImporter";
else if(Utility::String::endsWith(filename, ".dds")) else if(Utility::String::endsWith(normalized, ".dds"))
plugin = "DdsImporter"; plugin = "DdsImporter";
else if(Utility::String::endsWith(filename, ".exr")) else if(Utility::String::endsWith(normalized, ".exr"))
plugin = "OpenExrImporter"; plugin = "OpenExrImporter";
else if(Utility::String::endsWith(filename, ".gif")) else if(Utility::String::endsWith(normalized, ".gif"))
plugin = "GifImporter"; plugin = "GifImporter";
else if(Utility::String::endsWith(filename, ".hdr")) else if(Utility::String::endsWith(normalized, ".hdr"))
plugin = "HdrImporter"; plugin = "HdrImporter";
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 = "JpegImporter"; plugin = "JpegImporter";
else if(Utility::String::endsWith(filename, ".jp2")) else if(Utility::String::endsWith(normalized, ".jp2"))
plugin = "Jpeg2000Importer"; plugin = "Jpeg2000Importer";
else if(Utility::String::endsWith(filename, ".mng")) else if(Utility::String::endsWith(normalized, ".mng"))
plugin = "MngImporter"; plugin = "MngImporter";
else if(Utility::String::endsWith(filename, ".pbm")) else if(Utility::String::endsWith(normalized, ".pbm"))
plugin = "PbmImporter"; plugin = "PbmImporter";
else if(Utility::String::endsWith(filename, ".pcx")) else if(Utility::String::endsWith(normalized, ".pcx"))
plugin = "PcxImporter"; plugin = "PcxImporter";
else if(Utility::String::endsWith(filename, ".pgm")) else if(Utility::String::endsWith(normalized, ".pgm"))
plugin = "PgmImporter"; plugin = "PgmImporter";
else if(Utility::String::endsWith(filename, ".pic")) else if(Utility::String::endsWith(normalized, ".pic"))
plugin = "PicImporter"; plugin = "PicImporter";
else if(Utility::String::endsWith(filename, ".pnm")) else if(Utility::String::endsWith(normalized, ".pnm"))
plugin = "PnmImporter"; plugin = "PnmImporter";
else if(Utility::String::endsWith(filename, ".png")) else if(Utility::String::endsWith(normalized, ".png"))
plugin = "PngImporter"; plugin = "PngImporter";
else if(Utility::String::endsWith(filename, ".ppm")) else if(Utility::String::endsWith(normalized, ".ppm"))
plugin = "PpmImporter"; plugin = "PpmImporter";
else if(Utility::String::endsWith(filename, ".psd")) else if(Utility::String::endsWith(normalized, ".psd"))
plugin = "PsdImporter"; plugin = "PsdImporter";
else if(Utility::String::endsWith(filename, ".sgi") || else if(Utility::String::endsWith(normalized, ".sgi") ||
Utility::String::endsWith(filename, ".bw") || Utility::String::endsWith(normalized, ".bw") ||
Utility::String::endsWith(filename, ".rgb") || Utility::String::endsWith(normalized, ".rgb") ||
Utility::String::endsWith(filename, ".rgba")) Utility::String::endsWith(normalized, ".rgba"))
plugin = "SgiImporter"; plugin = "SgiImporter";
else if(Utility::String::endsWith(filename, ".tif") || else if(Utility::String::endsWith(normalized, ".tif") ||
Utility::String::endsWith(filename, ".tiff")) Utility::String::endsWith(normalized, ".tiff"))
plugin = "TiffImporter"; plugin = "TiffImporter";
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 = "TgaImporter"; plugin = "TgaImporter";
else { else {
Error() << "Trade::AnyImageImporter::openFile(): cannot determine type of file" << filename; Error() << "Trade::AnyImageImporter::openFile(): cannot determine type of file" << filename;

Loading…
Cancel
Save