File: exr2rgbe.cc

package info (click to toggle)
tinyexr 1.0.10%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,184 kB
  • sloc: cpp: 12,561; makefile: 110; sh: 18; ansic: 15
file content (38 lines) | stat: -rw-r--r-- 612 bytes parent folder | download | duplicates (4)
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;
}