rawls_update.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <iostream>
  4. #include <fstream>
  5. #include <vector>
  6. #include <tuple>
  7. #include "lodepng.h"
  8. #include "rawls.h"
  9. #include "rawls_v1.h"
  10. int main(int argc, char *argv[]){
  11. std::string imageName;
  12. std::string outfileName;
  13. for (int i = 1; i < argc; ++i) {
  14. if (!strcmp(argv[i], "--image") || !strcmp(argv[i], "-image")) {
  15. imageName = argv[++i];
  16. } else if (!strcmp(argv[i], "--outfile") || !strcmp(argv[i], "-outfile")) {
  17. outfileName = argv[++i];
  18. }
  19. }
  20. if (!(rawls::HasExtension(imageName, ".rawls"))){
  21. std::cout << "Unexpected `rawls` image name extension" << std::endl;
  22. return 1;
  23. }
  24. // std::cout << "Read image `" << imageName << "` and save it into " << outfileName << " into new RAWLS format" << std::endl;
  25. // get dimensions and data information from image
  26. unsigned width, height, nbChanels;
  27. float* buffer;
  28. std::tuple<unsigned, unsigned, unsigned, float*> data = rawls_v1::getDataRAWLS(imageName);
  29. width = std::get<0>(data);
  30. height = std::get<1>(data);
  31. nbChanels = std::get<2>(data);
  32. buffer = std::get<3>(data);
  33. auto comments = rawls_v1::getCommentsRAWLS(imageName);
  34. if (!(rawls::HasExtension(outfileName, ".rawls"))){
  35. std::cout << "Unexpected `rawls` image name extension" << std::endl;
  36. return 1;
  37. }
  38. rawls::saveAsRAWLS(width, height, nbChanels, comments, buffer, outfileName);
  39. }