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
|
#include <cstdio>
#include <cstdlib>
#include <vector>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
#include "tinyexr.h"
int main(int argc, char** argv)
{
if (argc < 3) {
printf("Usage: exr2rgbe input.exr output.hdr\n");
exit(-1);
}
int width, height;
float* rgba;
const char* err;
{
int ret = LoadEXR(&rgba, &width, &height, argv[1], &err);
if (ret != 0) {
printf("err: %s\n", err);
return -1;
}
}
{
int ret = stbi_write_hdr(argv[2], width, height, 4, rgba);
if (ret == 0) {
return -1; // fail
}
}
return 0;
}
|