\BaconQrCode\EncoderMaskUtil

Mask utility.

Summary

Methods
Properties
Constants
applyMaskPenaltyRule1()
applyMaskPenaltyRule2()
applyMaskPenaltyRule3()
applyMaskPenaltyRule4()
getDataMaskBit()
No public properties found
N1
N2
N3
N4
applyMaskPenaltyRule1Internal()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

N1

N1 = 3

N2

N2 = 3

N3

N3 = 40

N4

N4 = 10

Methods

applyMaskPenaltyRule1()

applyMaskPenaltyRule1(\BaconQrCode\Encoder\ByteMatrix  $matrix) : integer

Applies mask penalty rule 1 and returns the penalty.

Finds repetitive cells with the same color and gives penalty to them. Example: 00000 or 11111.

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix

Returns

integer

applyMaskPenaltyRule2()

applyMaskPenaltyRule2(\BaconQrCode\Encoder\ByteMatrix  $matrix) : integer

Applies mask penalty rule 2 and returns the penalty.

Finds 2x2 blocks with the same color and gives 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.

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix

Returns

integer

applyMaskPenaltyRule3()

applyMaskPenaltyRule3(\BaconQrCode\Encoder\ByteMatrix  $matrix) : integer

Applies mask penalty rule 3 and returns the penalty.

Finds consecutive cells of 00001011101 or 10111010000, and gives penalty to them. If we find patterns like 000010111010000, we give penalties twice (i.e. 40 * 2).

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix

Returns

integer

applyMaskPenaltyRule4()

applyMaskPenaltyRule4(\BaconQrCode\Encoder\ByteMatrix  $matrix) : integer

Applies mask penalty rule 4 and returns the penalty.

Calculates the ratio of dark cells and gives penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance.

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix

Returns

integer

getDataMaskBit()

getDataMaskBit(integer  $maskPattern, integer  $x, integer  $y) : integer

Returns the mask bit for "getMaskPattern" at "x" and "y".

See 8.8 of JISX0510:2004 for mask pattern conditions.

Parameters

integer $maskPattern
integer $x
integer $y

Throws

\BaconQrCode\Encoder\Exception\InvalidArgumentException

Returns

integer

applyMaskPenaltyRule1Internal()

applyMaskPenaltyRule1Internal(\BaconQrCode\Encoder\ByteMatrix  $matrix, boolean  $isHorizontal) : integer

Helper function for applyMaskPenaltyRule1.

We need this for doing this calculation in both vertical and horizontal orders respectively.

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix
boolean $isHorizontal

Returns

integer