! loads an image from a file with auto-detection of format */
| 37 | |
| 38 | /*! loads an image from a file with auto-detection of format */ |
| 39 | Ref<Image> loadImageFromDisk(const FileName& fileName) |
| 40 | { |
| 41 | std::string ext = toLowerCase(fileName.ext()); |
| 42 | |
| 43 | if (ext == "bmp" ) return loadSTB(fileName); |
| 44 | if (ext == "png" ) return loadSTB(fileName); |
| 45 | if (ext == "jpg" ) return loadSTB(fileName); |
| 46 | |
| 47 | if (ext == "exr" ) return loadEXR(fileName); |
| 48 | |
| 49 | if (ext == "pfm" ) return loadPFM(fileName); |
| 50 | if (ext == "ppm" ) return loadPPM(fileName); |
| 51 | if (ext == "tga" ) return loadTGA(fileName); |
| 52 | THROW_RUNTIME_ERROR("image format " + ext + " not supported"); |
| 53 | } |
| 54 | |
| 55 | static std::map<std::string,Ref<Image> > image_cache; |
| 56 |