iTextSharp.text.pdf.qrcode.ByteMatrix.GetArray C# (CSharp) Method

GetArray() public method

public GetArray ( ) : sbyte[][]
return sbyte[][]
        public sbyte[][] GetArray() {
            return bytes;
        }

Usage Example

Beispiel #1
0
        // Apply mask penalty rule 3 and return the penalty. Find consecutive cells of 00001011101 or
        // 10111010000, and give penalty to them.  If we find patterns like 000010111010000, we give
        // penalties twice (i.e. 40 * 2).
        public static int ApplyMaskPenaltyRule3(ByteMatrix matrix)
        {
            int penalty = 0;

            sbyte[][] array  = matrix.GetArray();
            int       width  = matrix.GetWidth();
            int       height = matrix.GetHeight();

            for (int y = 0; y < height; ++y)
            {
                for (int x = 0; x < width; ++x)
                {
                    // Tried to simplify following conditions but failed.
                    if (x + 6 < width &&
                        array[y][x] == 1 &&
                        array[y][x + 1] == 0 &&
                        array[y][x + 2] == 1 &&
                        array[y][x + 3] == 1 &&
                        array[y][x + 4] == 1 &&
                        array[y][x + 5] == 0 &&
                        array[y][x + 6] == 1 &&
                        ((x + 10 < width &&
                          array[y][x + 7] == 0 &&
                          array[y][x + 8] == 0 &&
                          array[y][x + 9] == 0 &&
                          array[y][x + 10] == 0) ||
                         (x - 4 >= 0 &&
                          array[y][x - 1] == 0 &&
                          array[y][x - 2] == 0 &&
                          array[y][x - 3] == 0 &&
                          array[y][x - 4] == 0)))
                    {
                        penalty += 40;
                    }
                    if (y + 6 < height &&
                        array[y][x] == 1 &&
                        array[y + 1][x] == 0 &&
                        array[y + 2][x] == 1 &&
                        array[y + 3][x] == 1 &&
                        array[y + 4][x] == 1 &&
                        array[y + 5][x] == 0 &&
                        array[y + 6][x] == 1 &&
                        ((y + 10 < height &&
                          array[y + 7][x] == 0 &&
                          array[y + 8][x] == 0 &&
                          array[y + 9][x] == 0 &&
                          array[y + 10][x] == 0) ||
                         (y - 4 >= 0 &&
                          array[y - 1][x] == 0 &&
                          array[y - 2][x] == 0 &&
                          array[y - 3][x] == 0 &&
                          array[y - 4][x] == 0)))
                    {
                        penalty += 40;
                    }
                }
            }
            return(penalty);
        }
All Usage Examples Of iTextSharp.text.pdf.qrcode.ByteMatrix::GetArray