-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathrotation.cpp
36 lines (29 loc) · 1.43 KB
/
rotation.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include "BitmapPlusPlus.hpp"
#include <iostream>
int main(void) {
try {
bmp::Bitmap image;
// Load the original bitmap
image.load(std::filesystem::path(ROOT_DIR) / "images" / "penguin.bmp");
// Test vertical flip
bmp::Bitmap flipped_v = image.flip_v();
flipped_v.save(std::filesystem::path(ROOT_DIR) / "images" / "rotated" / "penguin_flipped_v.bmp");
std::cout << "Vertical flip saved as penguin_flipped_v.bmp" << std::endl;
// Test horizontal flip
bmp::Bitmap flipped_h = image.flip_h();
flipped_h.save(std::filesystem::path(ROOT_DIR) / "images" / "rotated" / "penguin_flipped_h.bmp");
std::cout << "Horizontal flip saved as penguin_flipped_h.bmp" << std::endl;
// Test rotate 90 degrees to the right
bmp::Bitmap rotated_right = image.rotate_90_right();
rotated_right.save(std::filesystem::path(ROOT_DIR) / "images" / "rotated" / "penguin_rotated_right.bmp");
std::cout << "Rotated 90 degrees right saved as penguin_rotated_right.bmp" << std::endl;
// Test rotate 90 degrees to the left
bmp::Bitmap rotated_left = image.rotate_90_left();
rotated_left.save(std::filesystem::path(ROOT_DIR) / "images" / "rotated" / "penguin_rotated_left.bmp");
std::cout << "Rotated 90 degrees left saved as penguin_rotated_left.bmp" << std::endl;
return EXIT_SUCCESS;
} catch (const bmp::Exception& e) {
std::cerr << "Error: " << e.what() << std::endl;
return EXIT_FAILURE;
}
}