-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample1.cpp
40 lines (30 loc) · 1.28 KB
/
example1.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
37
38
39
40
#include <iostream>
#include <cmath>
#include <allheaders.h>
#include "pixwrap.h"
#include "get_rotation.h"
using derot::PixWrap;
int main(int argc, char* argv[])
{
if (argc < 3) {
std::cerr << "Usage: " << argv[0] << " <from_image_file> <to_file.png>" << std::endl;
return 1;
}
PixWrap pix {argv[1]};
int angle = derot::get_pix_rotation(pix);
std::cerr << "angle: " << angle << std::endl;
double angle_rad = angle * M_PI / 180;
std::cerr << "width : " << pixGetWidth (pix) << std::endl;
std::cerr << "height: " << pixGetHeight(pix) << std::endl;
auto [width, height] = derot::get_pix_rotation_wh(pix, angle);
std::cerr << "width : " << width << std::endl;
std::cerr << "height: " << height << std::endl;
PixWrap(pixRotate(pix, angle_rad, L_ROTATE_AREA_MAP, L_BRING_IN_WHITE, width, height )).writePng(argv[2]);
// PixWrap(pixRotate(pix, angle_rad, L_ROTATE_AREA_MAP, L_BRING_IN_WHITE, 0, 0 )).writePng("out-rot.png");
return 0;
}
// bin/example1.bin ../demo/1-in.jpg ../demo/1-out.png
// bin/example1.bin ../demo/2-in.jpg ../demo/2-out.png
// bin/example1.bin ../demo/3-in.jpg ../demo/3-out.png
// bin/example1.bin ../demo/4-in.jpg ../demo/4-out.png
// bin/example1.bin ../demo/5-in.jpg ../demo/5-out.png