Package com.google.zxing.qrcode.encoder
Class MaskUtil
- java.lang.Object
-
- com.google.zxing.qrcode.encoder.MaskUtil
-
final class MaskUtil extends java.lang.Object
-
-
Constructor Summary
Constructors Modifier Constructor Description private
MaskUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static int
applyMaskPenaltyRule1(ByteMatrix matrix)
Apply mask penalty rule 1 and return the penalty.private static int
applyMaskPenaltyRule1Internal(ByteMatrix matrix, boolean isHorizontal)
Helper function for applyMaskPenaltyRule1.(package private) static int
applyMaskPenaltyRule2(ByteMatrix matrix)
Apply mask penalty rule 2 and return the penalty.(package private) static int
applyMaskPenaltyRule3(ByteMatrix matrix)
Apply mask penalty rule 3 and return the penalty.(package private) static int
applyMaskPenaltyRule4(ByteMatrix matrix)
Apply mask penalty rule 4 and return the penalty.(package private) static boolean
getDataMaskBit(int maskPattern, int x, int y)
Return the mask bit for "getMaskPattern" at "x" and "y".private static boolean
isWhiteHorizontal(byte[] rowArray, int from, int to)
private static boolean
isWhiteVertical(byte[][] array, int col, int from, int to)
-
-
-
Field Detail
-
N1
private static final int N1
- See Also:
- Constant Field Values
-
N2
private static final int N2
- See Also:
- Constant Field Values
-
N3
private static final int N3
- See Also:
- Constant Field Values
-
N4
private static final int N4
- See Also:
- Constant Field Values
-
-
Method Detail
-
applyMaskPenaltyRule1
static int applyMaskPenaltyRule1(ByteMatrix matrix)
Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and give penalty to them. Example: 00000 or 11111.
-
applyMaskPenaltyRule2
static int applyMaskPenaltyRule2(ByteMatrix matrix)
Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give penalty to them. This is actually equivalent to the spec's rule, which is to find MxN blocks and give a penalty proportional to (M-1)x(N-1), because this is the number of 2x2 blocks inside such a block.
-
applyMaskPenaltyRule3
static int applyMaskPenaltyRule3(ByteMatrix matrix)
Apply mask penalty rule 3 and return the penalty. Find consecutive runs of 1:1:3:1:1:4 starting with black, or 4:1:1:3:1:1 starting with white, and give penalty to them. If we find patterns like 000010111010000, we give penalty once.
-
isWhiteHorizontal
private static boolean isWhiteHorizontal(byte[] rowArray, int from, int to)
-
isWhiteVertical
private static boolean isWhiteVertical(byte[][] array, int col, int from, int to)
-
applyMaskPenaltyRule4
static int applyMaskPenaltyRule4(ByteMatrix matrix)
Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.
-
getDataMaskBit
static boolean getDataMaskBit(int maskPattern, int x, int y)
Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask pattern conditions.
-
applyMaskPenaltyRule1Internal
private static int applyMaskPenaltyRule1Internal(ByteMatrix matrix, boolean isHorizontal)
Helper function for applyMaskPenaltyRule1. We need this for doing this calculation in both vertical and horizontal orders respectively.
-
-