Constants

POSITION_DETECTION_PATTERN

POSITION_DETECTION_PATTERN = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 1, 1, 1, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]]

Position detection pattern.

POSITION_ADJUSTMENT_PATTERN

POSITION_ADJUSTMENT_PATTERN = [[1, 1, 1, 1, 1], [1, 0, 0, 0, 1], [1, 0, 1, 0, 1], [1, 0, 0, 0, 1], [1, 1, 1, 1, 1]]

Position adjustment pattern.

POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE

POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE = [
    [null, null, null, null, null, null, null],
    // Version 1
    [6, 18, null, null, null, null, null],
    // Version 2
    [6, 22, null, null, null, null, null],
    // Version 3
    [6, 26, null, null, null, null, null],
    // Version 4
    [6, 30, null, null, null, null, null],
    // Version 5
    [6, 34, null, null, null, null, null],
    // Version 6
    [6, 22, 38, null, null, null, null],
    // Version 7
    [6, 24, 42, null, null, null, null],
    // Version 8
    [6, 26, 46, null, null, null, null],
    // Version 9
    [6, 28, 50, null, null, null, null],
    // Version 10
    [6, 30, 54, null, null, null, null],
    // Version 11
    [6, 32, 58, null, null, null, null],
    // Version 12
    [6, 34, 62, null, null, null, null],
    // Version 13
    [6, 26, 46, 66, null, null, null],
    // Version 14
    [6, 26, 48, 70, null, null, null],
    // Version 15
    [6, 26, 50, 74, null, null, null],
    // Version 16
    [6, 30, 54, 78, null, null, null],
    // Version 17
    [6, 30, 56, 82, null, null, null],
    // Version 18
    [6, 30, 58, 86, null, null, null],
    // Version 19
    [6, 34, 62, 90, null, null, null],
    // Version 20
    [6, 28, 50, 72, 94, null, null],
    // Version 21
    [6, 26, 50, 74, 98, null, null],
    // Version 22
    [6, 30, 54, 78, 102, null, null],
    // Version 23
    [6, 28, 54, 80, 106, null, null],
    // Version 24
    [6, 32, 58, 84, 110, null, null],
    // Version 25
    [6, 30, 58, 86, 114, null, null],
    // Version 26
    [6, 34, 62, 90, 118, null, null],
    // Version 27
    [6, 26, 50, 74, 98, 122, null],
    // Version 28
    [6, 30, 54, 78, 102, 126, null],
    // Version 29
    [6, 26, 52, 78, 104, 130, null],
    // Version 30
    [6, 30, 56, 82, 108, 134, null],
    // Version 31
    [6, 34, 60, 86, 112, 138, null],
    // Version 32
    [6, 30, 58, 86, 114, 142, null],
    // Version 33
    [6, 34, 62, 90, 118, 146, null],
    // Version 34
    [6, 30, 54, 78, 102, 126, 150],
    // Version 35
    [6, 24, 50, 76, 102, 128, 154],
    // Version 36
    [6, 28, 54, 80, 106, 132, 158],
    // Version 37
    [6, 32, 58, 84, 110, 136, 162],
    // Version 38
    [6, 26, 54, 82, 110, 138, 166],
    // Version 39
    [6, 30, 58, 86, 114, 142, 170],
]

Coordinates for position adjustment patterns for each version.

TYPE_INFO_COORDINATES

TYPE_INFO_COORDINATES = [[8, 0], [8, 1], [8, 2], [8, 3], [8, 4], [8, 5], [8, 7], [8, 8], [7, 8], [5, 8], [4, 8], [3, 8], [2, 8], [1, 8], [0, 8]]

Type information coordinates.

VERSION_INFO_POLY

VERSION_INFO_POLY = 0x1f25

Version information polynomial.

TYPE_INFO_POLY

TYPE_INFO_POLY = 0x537

Type information polynomial.

TYPE_INFO_MASK_PATTERN

TYPE_INFO_MASK_PATTERN = 0x5412

Type information mask pattern.

Methods

clearMatrix()

clearMatrix(\BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Clears a given matrix.

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix

buildMatrix()

buildMatrix(\BaconQrCode\Common\BitArray  $dataBits, \BaconQrCode\Common\ErrorCorrectionLevel  $level, \BaconQrCode\Common\Version  $version, int  $maskPattern, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Builds a complete matrix.

Parameters

\BaconQrCode\Common\BitArray $dataBits
\BaconQrCode\Common\ErrorCorrectionLevel $level
\BaconQrCode\Common\Version $version
int $maskPattern
\BaconQrCode\Encoder\ByteMatrix $matrix

removePositionDetectionPatterns()

removePositionDetectionPatterns(\BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Removes the position detection patterns from a matrix.

This can be useful if you need to render those patterns separately.

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix

embedTypeInfo()

embedTypeInfo(\BaconQrCode\Common\ErrorCorrectionLevel  $level, int  $maskPattern, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds type information into a matrix.

Parameters

\BaconQrCode\Common\ErrorCorrectionLevel $level
int $maskPattern
\BaconQrCode\Encoder\ByteMatrix $matrix

makeTypeInfoBits()

makeTypeInfoBits(\BaconQrCode\Common\ErrorCorrectionLevel  $level, int  $maskPattern, \BaconQrCode\Common\BitArray  $bits) : void

Generates type information bits and appends them to a bit array.

Parameters

\BaconQrCode\Common\ErrorCorrectionLevel $level
int $maskPattern
\BaconQrCode\Common\BitArray $bits

Throws

\BaconQrCode\Exception\RuntimeException

if bit array resulted in invalid size

maybeEmbedVersionInfo()

maybeEmbedVersionInfo(\BaconQrCode\Common\Version  $version, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds version information if required.

Parameters

\BaconQrCode\Common\Version $version
\BaconQrCode\Encoder\ByteMatrix $matrix

makeVersionInfoBits()

makeVersionInfoBits(\BaconQrCode\Common\Version  $version, \BaconQrCode\Common\BitArray  $bits) : void

Generates version information bits and appends them to a bit array.

Parameters

\BaconQrCode\Common\Version $version
\BaconQrCode\Common\BitArray $bits

Throws

\BaconQrCode\Exception\RuntimeException

if bit array resulted in invalid size

calculateBchCode()

calculateBchCode(int  $value, int  $poly) : int

Calculates the BCH code for a value and a polynomial.

Parameters

int $value
int $poly

Returns

int —

findMsbSet()

findMsbSet(int  $value) : int

Finds and MSB set.

Parameters

int $value

Returns

int —

embedBasicPatterns()

embedBasicPatterns(\BaconQrCode\Common\Version  $version, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds basic patterns into a matrix.

Parameters

\BaconQrCode\Common\Version $version
\BaconQrCode\Encoder\ByteMatrix $matrix

embedPositionDetectionPatternsAndSeparators()

embedPositionDetectionPatternsAndSeparators(\BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds position detection patterns and separators into a byte matrix.

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix

embedPositionDetectionPattern()

embedPositionDetectionPattern(int  $xStart, int  $yStart, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds a single position detection pattern into a byte matrix.

Parameters

int $xStart
int $yStart
\BaconQrCode\Encoder\ByteMatrix $matrix

removePositionDetectionPattern()

removePositionDetectionPattern(int  $xStart, int  $yStart, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Parameters

int $xStart
int $yStart
\BaconQrCode\Encoder\ByteMatrix $matrix

embedHorizontalSeparationPattern()

embedHorizontalSeparationPattern(int  $xStart, int  $yStart, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds a single horizontal separation pattern.

Parameters

int $xStart
int $yStart
\BaconQrCode\Encoder\ByteMatrix $matrix

Throws

\BaconQrCode\Exception\RuntimeException

if a byte was already set

embedVerticalSeparationPattern()

embedVerticalSeparationPattern(int  $xStart, int  $yStart, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds a single vertical separation pattern.

Parameters

int $xStart
int $yStart
\BaconQrCode\Encoder\ByteMatrix $matrix

Throws

\BaconQrCode\Exception\RuntimeException

if a byte was already set

embedDarkDotAtLeftBottomCorner()

embedDarkDotAtLeftBottomCorner(\BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds a dot at the left bottom corner.

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix

Throws

\BaconQrCode\Exception\RuntimeException

if a byte was already set to 0

maybeEmbedPositionAdjustmentPatterns()

maybeEmbedPositionAdjustmentPatterns(\BaconQrCode\Common\Version  $version, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds position adjustment patterns if required.

Parameters

\BaconQrCode\Common\Version $version
\BaconQrCode\Encoder\ByteMatrix $matrix

embedPositionAdjustmentPattern()

embedPositionAdjustmentPattern(int  $xStart, int  $yStart, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds a single position adjustment pattern.

Parameters

int $xStart
int $yStart
\BaconQrCode\Encoder\ByteMatrix $matrix

embedTimingPatterns()

embedTimingPatterns(\BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds timing patterns into a matrix.

Parameters

\BaconQrCode\Encoder\ByteMatrix $matrix

embedDataBits()

embedDataBits(\BaconQrCode\Common\BitArray  $dataBits, int  $maskPattern, \BaconQrCode\Encoder\ByteMatrix  $matrix) : void

Embeds "dataBits" using "getMaskPattern".

For debugging purposes, it skips masking process if "getMaskPattern" is -1. See 8.7 of JISX0510:2004 (p.38) for how to embed data bits.

Parameters

\BaconQrCode\Common\BitArray $dataBits
int $maskPattern
\BaconQrCode\Encoder\ByteMatrix $matrix

Throws

\BaconQrCode\Exception\WriterException

if not all bits could be consumed