Add check when building padding table.
This commit is contained in:
parent
f2234dea1f
commit
7ac7522908
43
rotation.cpp
43
rotation.cpp
|
@ -211,21 +211,42 @@ uint16_t* generate_padding_table(Image const& rotated,
|
|||
|
||||
padding_table[i] = max(x_range, y_range);
|
||||
|
||||
{
|
||||
Point test(src_rotated_origin.x + padding_table[i] * qdx.x,
|
||||
Point border(src_rotated_origin.x + padding_table[i] * qdx.x,
|
||||
src_rotated_origin.y + padding_table[i] * qdx.y);
|
||||
if (test.x < 0 || test.y < 0
|
||||
|| test.x >= src_qwidth || test.y >= src_qheight)
|
||||
if (border.x < 0 || border.y < 0
|
||||
|| border.x >= src_qwidth || border.y >= src_qheight)
|
||||
{
|
||||
if (false)
|
||||
{
|
||||
cout << "Padding issue at line " << i << endl;
|
||||
cout << " src: " << src_rotated_origin << endl;
|
||||
cout << " test: " << test << endl;
|
||||
cout << " q dim: " << src_qwidth << " x " << src_qheight << endl;
|
||||
cout << " " << padding_table[i] << " x " << qdx << endl;
|
||||
cout << " x diff = " << src_rotated_origin.x - src_qwidth + 1 << endl;
|
||||
cout << " x coef = " << (float) (src_rotated_origin.x - src_qwidth + 1) / (float) (-qdx.x) << endl;
|
||||
LOG << "Padding issue at line " << i << endl;
|
||||
LOG << " origin: " << src_rotated_origin << endl;
|
||||
LOG << " border: " << border << endl;
|
||||
LOG << " q dim: " << src_qwidth << " x " << src_qheight << endl;
|
||||
LOG << " " << padding_table[i] << " x " << qdx << endl;
|
||||
LOG << " X range" << endl;
|
||||
LOG << " x diff = " << src_rotated_origin.x - src_qwidth + 1 << endl;
|
||||
LOG << " x coef = " << (float) (src_rotated_origin.x - src_qwidth + 1) / (float) (-qdx.x) << endl;
|
||||
LOG << " Y range" << endl;
|
||||
if (src_rotated_origin.y < 0)
|
||||
{
|
||||
LOG << " y < 0" << endl;
|
||||
LOG << " y diff = " << (-src_rotated_origin.y) << endl;
|
||||
LOG << " y coef = " << (-src_rotated_origin.y) / (float) qdx.y << endl;
|
||||
}
|
||||
else if (src_rotated_origin.y >= src_qheight)
|
||||
{
|
||||
LOG << " y < height" << endl;
|
||||
LOG << " y diff = " << src_rotated_origin.x - src_qwidth + 1 << endl;
|
||||
LOG << " y coef = " << (float) (src_rotated_origin.x - src_qwidth + 1) / (float) (-qdx.x) << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG << " in bounds" << endl;
|
||||
}
|
||||
abort();
|
||||
}
|
||||
|
||||
padding_table[i] = rotated.width;
|
||||
}
|
||||
|
||||
src_rotated_origin += qdy;
|
||||
|
|
Loading…
Reference in a new issue