Advertisement
kolbka_

main

Apr 27th, 2022
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1.  
  2. #include "../include/exceptions.h"
  3. #include "../include/image.h"
  4.  
  5. int main([[maybe_unused]] int argc, char *argv[]) {
  6. try {
  7. std::string method = argv[1];
  8.  
  9. if (argc != 8) {
  10. throw less_arguments();
  11. }
  12.  
  13. std::string name_input_file = argv[2];
  14. std::string name_output_file = argv[3];
  15. int x = std::stoi(argv[4]);
  16. int y = std::stoi(argv[5]);
  17. int w = std::stoi(argv[6]);
  18. int h = std::stoi(argv[7]);
  19.  
  20. auto cur_image = lab_bmp::image(name_input_file);
  21.  
  22. try {
  23. if (method == "crop-rotate") {
  24. cur_image.cropp(x, y, w, h);
  25. cur_image.rotate();
  26. } else if (method == "crop") {
  27. cur_image.cropp(x, y, w, h);
  28. } else if (method == "rotate") {
  29. cur_image.rotate();
  30. }
  31. cur_image.write(name_output_file);
  32. } catch (std::bad_alloc &) {
  33. throw bad_memory();
  34. }
  35. } catch (std::exception &e) {
  36. std::cerr << e.what() << std::endl;
  37. return 1;
  38. }
  39. return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement