Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "../include/exceptions.h"
- #include "../include/image.h"
- int main([[maybe_unused]] int argc, char *argv[]) {
- try {
- std::string method = argv[1];
- if (argc != 8) {
- throw less_arguments();
- }
- std::string name_input_file = argv[2];
- std::string name_output_file = argv[3];
- int x = std::stoi(argv[4]);
- int y = std::stoi(argv[5]);
- int w = std::stoi(argv[6]);
- int h = std::stoi(argv[7]);
- auto cur_image = lab_bmp::image(name_input_file);
- try {
- if (method == "crop-rotate") {
- cur_image.cropp(x, y, w, h);
- cur_image.rotate();
- } else if (method == "crop") {
- cur_image.cropp(x, y, w, h);
- } else if (method == "rotate") {
- cur_image.rotate();
- }
- cur_image.write(name_output_file);
- } catch (std::bad_alloc &) {
- throw bad_memory();
- }
- } catch (std::exception &e) {
- std::cerr << e.what() << std::endl;
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement