iTextSharp.text.pdf.qrcode.MaskUtil.ApplyMaskPenaltyRule2 C# (CSharp) Method

ApplyMaskPenaltyRule2() public static method

public static ApplyMaskPenaltyRule2 ( ByteMatrix matrix ) : int
matrix ByteMatrix
return int
        public static int ApplyMaskPenaltyRule2(ByteMatrix matrix) {
            int penalty = 0;
            sbyte[][] array = matrix.GetArray();
            int width = matrix.GetWidth();
            int height = matrix.GetHeight();
            for (int y = 0; y < height - 1; ++y) {
                for (int x = 0; x < width - 1; ++x) {
                    int value = array[y][x];
                    if (value == array[y][x + 1] && value == array[y + 1][x] && value == array[y + 1][x + 1]) {
                        penalty += 3;
                    }
                }
            }
            return penalty;
        }

Usage Example

コード例 #1
0
        // The mask penalty calculation is complicated.  See Table 21 of JISX0510:2004 (p.45) for details.
        // Basically it applies four rules and summate all penalties.
        private static int CalculateMaskPenalty(ByteMatrix matrix)
        {
            var penalty = 0;

            penalty += MaskUtil.ApplyMaskPenaltyRule1(matrix);
            penalty += MaskUtil.ApplyMaskPenaltyRule2(matrix);
            penalty += MaskUtil.ApplyMaskPenaltyRule3(matrix);
            penalty += MaskUtil.ApplyMaskPenaltyRule4(matrix);
            return(penalty);
        }