Beispiel #1
0
 /**
  * ファイルロード[拡張子自動判別]
  * @param filepath  ファイルフルパス 
  * @retval true 成功
  * @retval false 失敗
  */
 bool Load(const char* filename)
 {
     bool result = false;
     m_image.Clear();
     std::string path(filename);
     std::string::size_type pos = path.rfind('.');
     if (pos != std::string::npos)
     {
         const std::string ext = make_lowercase(path.substr(pos+1));
         if (ext == "png")
         {
             result = LoadPNG(path);
         }
         else if (ext == "jpg" || ext == "jpeg")
         {
             result = LoadJPG(path);
         }
         else if (ext == "tga")
         {
             result = LoadTGA(path);
         }
         else if (ext == "hdr")
         {
             result = LoadHDR(path);
         }
         else if (ext == "exr" || ext == "EXR")
         {
             result = LoadEXR(path);
         }
     }
     return result;
 }
Beispiel #2
0
void InfiniteAreaLight::readExr(std::string const& filename) {
    // std::cout << "Reading EXR: " << filename << std::endl;
    const char* err = nullptr;

    int ret = LoadEXR(&data, &width, &height, filename.c_str(), &err);

    if (ret != TINYEXR_SUCCESS) {
        if (err) {
            fprintf(stderr, "ERR : %s\n", err);
            FreeEXRErrorMessage(err);  // release memory of error message.
        }
    }
}
Beispiel #3
0
int main(int argc, char** argv)
{
  float *rgba;
  const char* err;
  int width;
  int height;

  if (argc < 2) {
    return EXIT_FAILURE;
  }

  int ret = LoadEXR(&rgba, &width, &height, argv[1], &err);

  return ret; 
}
Beispiel #4
0
static RGBSpectrum *ReadImageEXR(const std::string &name, int *width,
                                 int *height) {
    float *pixels;
    const char *err;
    if (LoadEXR(&pixels, width, height, name.c_str(), &err)) {
        Error("Unable to read \"%s\": %s", name.c_str(), err);
        return nullptr;
    }
    RGBSpectrum *ret = new RGBSpectrum[*width * *height];
    int rOffset = 0;
    for (int y = 0; y < *height; ++y) {
        int pOffset = (*height - 1 - y) * *width;
        for (int x = 0; x < *width; ++x, ++pOffset, ++rOffset)
            ret[rOffset] = RGBSpectrum::FromRGB(&pixels[4 * pOffset]);
    }
    return ret;
}