Пример #1
0
  /*! loads an image from a file with auto-detection of format */
  Ref<Image> loadImageFromDisk(const FileName& fileName) try
  {
    std::string ext = std::strlwr(fileName.ext());
#ifdef USE_OPENEXR
    if (ext == "exr" ) return loadExr(fileName);
#endif
#ifdef USE_IMAGEMAGICK
    if (ext == "bmp" ) return loadMagick(fileName);
    if (ext == "gif" ) return loadMagick(fileName);
    if (ext == "png" ) return loadMagick(fileName);
    if (ext == "tga" ) return loadMagick(fileName);
    if (ext == "tif" ) return loadMagick(fileName);
    if (ext == "tiff") return loadMagick(fileName);
#endif
#ifdef USE_LIBJPEG
    if (ext == "jpg" ) return loadJPEG(fileName);
#endif
    if (ext == "pfm" ) return loadPFM(fileName);
    if (ext == "ppm" ) return loadPPM(fileName);
    throw std::runtime_error("image format " + ext + " not supported");
  }
  catch (const std::exception& e) {
    std::cout << "cannot read file " << fileName << ": " << e.what() << std::endl;
    return null;
  }
Пример #2
0
std::unique_ptr<float[]> loadHdr(const Path &path, TexelConversion request, int &w, int &h)
{
    if (path.testExtension("pfm"))
        return std::move(loadPfm(path, request, w, h));
#if OPENEXR_AVAILABLE
    else if (path.testExtension("exr"))
        return std::move(loadExr(path, request, w, h));
#endif
    else
        return std::move(loadStbiHdr(path, request, w, h));
}