Menu

#4 Bug in "InsertPaddingBytes" function

v1.0 (example)
open
None
5
2018-05-23
2018-05-23
No

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:

    • When margin is not zero and the module size odd.
  • When margin is 1 and the module size is even.

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.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB