-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
49 lines (41 loc) · 1.38 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <iostream>
#include <string>
#include <fstream>
#include "converter.hpp"
using namespace std;
// The user provides an HRDi image as input and outputs a radiance image in exr format
int main(int argc, char *argv[])
{
// Check if the user provided the correct number of arguments
if(argc <=2)
{
std::cout << "Usage: " << argv[0] << " <input_image.hdr> <output_radiance_image.exr>" << std::endl;
return 1;
}
// Check if the input file exists
string input_file = argv[1];
ifstream file(input_file);
if (!file.good())
{
cout << "Error: The input file " << input_file << " does not exist." << std::endl;
return 1;
}
// Check if the input file is an HDR image
if (input_file.substr(input_file.find_last_of(".") + 1) != "hdr")
{
cout << "Error: The input file " << input_file << " is not an HDR image." << std::endl;
return 1;
}
// Check if the output file is an EXR image
string output_file = argv[2];
if (output_file.substr(output_file.find_last_of(".") + 1) != "exr")
{
cout << "Error: The output file " << output_file << " is not an EXR image." << endl;
return 1;
}
// Create a converter object and process the input image to generate the output image
converter conv(input_file);
conv.process();
conv.save(output_file);
return 0;
}