🛠️🐜 Antkeeper superbuild with dependencies included https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.1 KiB

  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <vector>
  4. #define STB_IMAGE_RESIZE_IMPLEMENTATION
  5. #include "stb_image_resize.h"
  6. #include "tinyexr.h"
  7. int main(int argc, char** argv)
  8. {
  9. if (argc < 5) {
  10. printf("Usage: exrresize input.exr output.exr dst_width dst_height.\n");
  11. printf(" Only supports RGB or RGBA EXR input.\n");
  12. exit(-1);
  13. }
  14. int dst_width = atoi(argv[3]);
  15. int dst_height = atoi(argv[4]);
  16. int width, height;
  17. float* rgba;
  18. const char* err;
  19. {
  20. int ret = LoadEXR(&rgba, &width, &height, argv[1], &err);
  21. if (ret != TINYEXR_SUCCESS) {
  22. printf("err: %s\n", err);
  23. return -1;
  24. }
  25. }
  26. std::vector<float> buf(dst_width * dst_height * 4);
  27. int ret = stbir_resize_float(rgba, width, height, width*4*sizeof(float), &buf.at(0), dst_width, dst_height,dst_width*4*sizeof(float), 4);
  28. assert(ret != 0);
  29. ret = SaveEXR(buf.data(), dst_width, dst_height, 4, /*fp16*/0, argv[2], &err);
  30. if (ret != TINYEXR_SUCCESS) {
  31. if (err) {
  32. fprintf(stderr, "err: %s\n", err);
  33. FreeEXRErrorMessage(err);
  34. }
  35. }
  36. return (ret == TINYEXR_SUCCESS);
  37. }