Class MaskUtil
java.lang.Object
com.itextpdf.barcodes.qrcode.MaskUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intapplyMaskPenaltyRule1(ByteMatrix matrix) Apply mask penalty rule 1 and return the penalty.private static intapplyMaskPenaltyRule1Internal(ByteMatrix matrix, boolean isHorizontal) static intapplyMaskPenaltyRule2(ByteMatrix matrix) Apply mask penalty rule 2 and return the penalty.static intapplyMaskPenaltyRule3(ByteMatrix matrix) Apply mask penalty rule 3 and return the penalty.static intapplyMaskPenaltyRule4(ByteMatrix matrix) Apply mask penalty rule 4 and return the penalty.static booleangetDataMaskBit(int maskPattern, int x, int y) Return the mask bit for "getMaskPattern" at "x" and "y".
-
Constructor Details
-
MaskUtil
private MaskUtil()
-
-
Method Details
-
applyMaskPenaltyRule1
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.- Parameters:
matrix- ByteMatrix to apply the penalty rule to- Returns:
- the rule 1 penalty
-
applyMaskPenaltyRule2
Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give penalty to them.- Parameters:
matrix- ByteMatrix to apply the penalty rule to- Returns:
- the rule 2 penalty
-
applyMaskPenaltyRule3
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).- Parameters:
matrix- ByteMatrix to apply the penalty rule to- Returns:
- the rule 3 penalty
-
applyMaskPenaltyRule4
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. Examples: - 0% => 100 - 40% => 20 - 45% => 10 - 50% => 0 - 55% => 10 - 55% => 20 - 100% => 100- Parameters:
matrix- Bytematrix to apply the rule to- Returns:
- the rule 4 penalty
-
getDataMaskBit
public 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.- Parameters:
maskPattern- masking pattern to usex- width coordiantey- height-coordinate- Returns:
- the mask bit at that position
-
applyMaskPenaltyRule1Internal
-