Add print_padding_table().
This commit is contained in:
parent
8febb99bf9
commit
b008cccb95
43
rotation.cpp
43
rotation.cpp
|
@ -199,7 +199,6 @@ uint16_t* generate_padding_table(Image const& src,
|
||||||
// TODO: we should be able to infer these values from qdx and qdy
|
// TODO: we should be able to infer these values from qdx and qdy
|
||||||
DPoint const top_left_grid = get_mapped_point(src, Point(0, 0), padding_rotation);
|
DPoint const top_left_grid = get_mapped_point(src, Point(0, 0), padding_rotation);
|
||||||
Point const top_left = convert_img_coord(rotated, top_left_grid);
|
Point const top_left = convert_img_coord(rotated, top_left_grid);
|
||||||
cout << "Padding top left: " << top_left << endl;
|
|
||||||
|
|
||||||
DPoint const top_right_grid = get_mapped_point(src, Point(src.width - 1, 0), padding_rotation);
|
DPoint const top_right_grid = get_mapped_point(src, Point(src.width - 1, 0), padding_rotation);
|
||||||
DPoint const top_right = convert_img_coord_precision(rotated, top_right_grid);
|
DPoint const top_right = convert_img_coord_precision(rotated, top_right_grid);
|
||||||
|
@ -233,6 +232,44 @@ uint16_t* generate_padding_table(Image const& src,
|
||||||
return padding_table;
|
return padding_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_padding_table(uint16_t const* padding_table,
|
||||||
|
unsigned int size)
|
||||||
|
{
|
||||||
|
cout << "Padding table:" << endl;
|
||||||
|
|
||||||
|
for (unsigned int i = 0; i < size; ++i)
|
||||||
|
{
|
||||||
|
int left_padding = padding_table[i];
|
||||||
|
int right_padding = padding_table[size - 1 - i];
|
||||||
|
int core_pixels = size - left_padding - right_padding;
|
||||||
|
|
||||||
|
if (core_pixels < 0)
|
||||||
|
{
|
||||||
|
cout << "Too much padding at line " << i << endl;
|
||||||
|
cout << " left padding = " << left_padding << endl;
|
||||||
|
cout << " right padding = " << right_padding << endl;
|
||||||
|
cout << " max size = " << size << endl;
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << " [";
|
||||||
|
for (int j = 0; j < left_padding; ++j)
|
||||||
|
cout << " ";
|
||||||
|
for (int j = 0; j < core_pixels; ++j)
|
||||||
|
cout << "x";
|
||||||
|
for (int j = 0; j < right_padding; ++j)
|
||||||
|
cout << " ";
|
||||||
|
cout << "]" << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Image rotation
|
||||||
|
//
|
||||||
|
|
||||||
inline
|
inline
|
||||||
void rotate_pixel(Image const& src,
|
void rotate_pixel(Image const& src,
|
||||||
Point const& src_rotated_point,
|
Point const& src_rotated_point,
|
||||||
|
@ -343,6 +380,10 @@ Image* rotate(Image const& src, double angle)
|
||||||
|
|
||||||
Point src_rotated_origin(rot_origin_in_src.x * q_pos,
|
Point src_rotated_origin(rot_origin_in_src.x * q_pos,
|
||||||
rot_origin_in_src.y * q_pos);
|
rot_origin_in_src.y * q_pos);
|
||||||
|
// Padding
|
||||||
|
uint16_t* padding_table = generate_padding_table(src, *rotated, rotation, q_pos);
|
||||||
|
//print_padding_table(padding_table, border_table, height, true);
|
||||||
|
|
||||||
for (int y = 0; y < height; ++y)
|
for (int y = 0; y < height; ++y)
|
||||||
{
|
{
|
||||||
Point src_rotated_point = src_rotated_origin;
|
Point src_rotated_point = src_rotated_origin;
|
||||||
|
|
Loading…
Reference in a new issue