Bug in "InsertPaddingBytes" function
Status: Beta
Brought to you by:
michivo
Hi,
there is a bug in the "InsertPaddingBytes" function. Normally you do not see the effect but in the following cases you will see that depending on the padding the some column(s) of the left solid foreground colored columns will be white for DataMatrix. The conditions are:
But these conditions only make the bug visible. The bug is there.
Problem is in the following part:
for (int j = 0; j < width; j++)
{
newData[i * paddedWidth + 3 * j] = data[3 * (i * width + j)];
newData[i * paddedWidth + 3 * j + 1] = data[3 * (i * width + j) + 1];
newData[i * paddedWidth + 3 * j + 2] = data[3 * (i * width + j) + 2];
}
for (int k = 0; k < padding; k++)
{
newData[i * paddedWidth + 3 * k] = 255;
newData[i * paddedWidth + 3 * k + 1] = 255;
newData[i * paddedWidth + 3 * k + 2] = 255;
}
Here the second "for" loop overwrites the padding times columns of the data array. A possible solution is as follows:
int j;
for (j = 0; j < width; j++)
{
newData[i * paddedWidth + 3 * j] = data[3 * (i * width + j)];
newData[i * paddedWidth + 3 * j + 1] = data[3 * (i * width + j) + 1];
newData[i * paddedWidth + 3 * j + 2] = data[3 * (i * width + j) + 2];
}
for (int k = 0; k < padding; k++)
{
newData[i * paddedWidth + 3 * j + k] = 255;
}
Can you please check?
Br,
Murat Y.