kolbka_

Untitled

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