Add borders in padding printing.

This commit is contained in:
Fabien Freling 2014-08-05 22:42:31 +02:00
parent 57c5052908
commit 7f1bd27ac0

View file

@ -233,6 +233,7 @@ uint16_t* generate_padding_table(Image const& src,
}
void print_padding_table(uint16_t const* padding_table,
uint16_t const* border_table,
unsigned int size)
{
cout << "Padding table:" << endl;
@ -240,23 +241,32 @@ void print_padding_table(uint16_t const* padding_table,
for (unsigned int i = 0; i < size; ++i)
{
int left_padding = padding_table[i];
int left_border = border_table[i];
int right_padding = padding_table[size - 1 - i];
int core_pixels = size - left_padding - right_padding;
int right_border = border_table[size - 1 - i];
int core_pixels = size - left_padding - right_padding - left_border - right_border;
if (core_pixels < 0)
{
cout << "Too much padding at line " << i << endl;
cout << " left padding = " << left_padding << endl;
cout << "Too much padding + border at line " << i << endl;
cout << " left padding = " << left_padding << endl;
cout << " left border = " << left_border << endl;
cout << " right padding = " << right_padding << endl;
cout << " max size = " << size << endl;
cout << " right border = " << right_border << endl;
cout << " total = " << left_padding + left_border + right_border + right_padding << endl;
cout << " max size = " << size << endl;
abort();
}
cout << " [";
for (int j = 0; j < left_padding; ++j)
cout << " ";
for (int j = 0; j < left_border; ++j)
cout << ".";
for (int j = 0; j < core_pixels; ++j)
cout << "x";
for (int j = 0; j < right_border; ++j)
cout << ".";
for (int j = 0; j < right_padding; ++j)
cout << " ";
cout << "]" << endl;