Documentation

BitMatrix extends QRMatrix
in package

Holds a numerical representation of the final QR Code; maps the ECC coded binary data and applies the mask pattern

Table of Contents

IS_DARK  = 0b100000000000
M_ALIGNMENT  = 0b10000
M_DARKMODULE  = 0b1
M_DATA  = 0b10
M_FINDER  = 0b100
M_FINDER_DOT  = 0b10000000000
M_FORMAT  = 0b1000000
M_LOGO  = 0b1000000000
M_NULL  = 0b0
M_QUIETZONE  = 0b100000000
M_SEPARATOR  = 0b1000
M_TEST  = 0b11111111111
M_TIMING  = 0b100000
M_VERSION  = 0b10000000
DECODE_LOOKUP  = [0x0 => 0x5412, 0x1 => 0x5125, 0x2 => 0x5e7c, 0x3 => 0x5b4b, 0x4 => 0x45f9, 0x5 => 0x40ce, 0x6 => 0x4f97, 0x7 => 0x4aa0, 0x8 => 0x77c4, 0x9 => 0x72f3, 0xa => 0x7daa, 0xb => 0x789d, 0xc => 0x662f, 0xd => 0x6318, 0xe => 0x6c41, 0xf => 0x6976, 0x10 => 0x1689, 0x11 => 0x13be, 0x12 => 0x1ce7, 0x13 => 0x19d0, 0x14 => 0x762, 0x15 => 0x255, 0x16 => 0xd0c, 0x17 => 0x83b, 0x18 => 0x355f, 0x19 => 0x3068, 0x1a => 0x3f31, 0x1b => 0x3a06, 0x1c => 0x24b4, 0x1d => 0x2183, 0x1e => 0x2eda, 0x1f => 0x2bed]
See ISO 18004:2006, Annex C, Table C.1
FORMAT_INFO_MASK_QR  = 0x5412
$eccLevel  : EccLevel|null
the current ECC level
$maskPattern  : MaskPattern|null
the used mask pattern, set via QRMatrix::mask()
$matrix  : array<string|int, mixed>
the actual matrix data array
$moduleCount  : int
the size (side length) of the matrix, including quiet zone (if created)
$version  : Version|null
a Version instance
$mirror  : bool
__construct()  : mixed
QRMatrix constructor.
check()  : bool
Checks whether a module is true (dark) or false (light)
checkType()  : bool
Checks whether a module is of the given $M_TYPE
checkTypes()  : bool
checks whether a module matches one of the given $M_TYPES
eccLevel()  : EccLevel|null
Returns the current ECC level
flip()  : self
Flips the value of the module
get()  : int
Returns the value of the module at position [$x, $y]
initFunctionalPatterns()  : self
shortcut to initialize the functional patterns
mask()  : self
Applies/reverses the mask pattern
maskPattern()  : MaskPattern|null
Returns the current mask pattern
matrix()  : array<string|int, array<string|int, int>>|array<string|int, array<string|int, bool>>
Returns the data matrix, returns a pure boolean representation if $boolean is set to true
mirror()  : self
Mirror the bit matrix in order to attempt a second reading.
readCodewords()  : array<string|int, mixed>
Reads the bits in the BitMatrix representing the finder pattern in the correct order in order to reconstruct the codewords bytes contained within the QR Code.
set()  : self
Sets the $M_TYPE value for the module at position [$x, $y]
setAlignmentPattern()  : self
Draws the 5x5 alignment patterns
setDarkModule()  : self
Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder
setFinderPattern()  : self
Draws the 7x7 finder patterns in the corners top left/right and bottom left
setFormatInfo()  : self
Draws the format info along the finder patterns
setLogoSpace()  : self
Clears a space of $width * $height in order to add a logo or text.
setMirror()  : self
Prepare the parser for a mirrored operation.
setQuietZone()  : self
Draws the "quiet zone" of $size around the matrix
setSeparators()  : self
Draws the separator lines around the finder patterns
setTimingPattern()  : self
Draws the timing pattern (h/v checkered line between the finder patterns)
setVersionNumber()  : self
Draws the version information, 2x 3x6 pixel
size()  : int
Returns the absoulute size of the matrix, including quiet zone (after setting it).
version()  : Version|null
Returns the current version number
writeCodewords()  : self
Maps the interleaved binary $data on the matrix
copyVersionBit()  : int
decodeVersionInformation()  : Version|null
doDecodeFormatInformation()  : int|null
numBitsDiffering()  : int
readFormatInformation()  : self
Reads format information from one of its two locations within the QR Code.
readVersion()  : self
Reads version information from one of its two locations within the QR Code.
uRShift()  : int

Constants

IS_DARK

public int IS_DARK = 0b100000000000

M_ALIGNMENT

public int M_ALIGNMENT = 0b10000

M_DARKMODULE

public int M_DARKMODULE = 0b1

M_FINDER_DOT

public int M_FINDER_DOT = 0b10000000000

M_FORMAT

public int M_FORMAT = 0b1000000

M_QUIETZONE

public int M_QUIETZONE = 0b100000000

M_SEPARATOR

public int M_SEPARATOR = 0b1000

M_TEST

public int M_TEST = 0b11111111111

M_VERSION

public int M_VERSION = 0b10000000

DECODE_LOOKUP

See ISO 18004:2006, Annex C, Table C.1

private mixed DECODE_LOOKUP = [0x0 => 0x5412, 0x1 => 0x5125, 0x2 => 0x5e7c, 0x3 => 0x5b4b, 0x4 => 0x45f9, 0x5 => 0x40ce, 0x6 => 0x4f97, 0x7 => 0x4aa0, 0x8 => 0x77c4, 0x9 => 0x72f3, 0xa => 0x7daa, 0xb => 0x789d, 0xc => 0x662f, 0xd => 0x6318, 0xe => 0x6c41, 0xf => 0x6976, 0x10 => 0x1689, 0x11 => 0x13be, 0x12 => 0x1ce7, 0x13 => 0x19d0, 0x14 => 0x762, 0x15 => 0x255, 0x16 => 0xd0c, 0x17 => 0x83b, 0x18 => 0x355f, 0x19 => 0x3068, 0x1a => 0x3f31, 0x1b => 0x3a06, 0x1c => 0x24b4, 0x1d => 0x2183, 0x1e => 0x2eda, 0x1f => 0x2bed]

[data bits, sequence after masking]

FORMAT_INFO_MASK_QR

private mixed FORMAT_INFO_MASK_QR = 0x5412

Properties

$maskPattern

the used mask pattern, set via QRMatrix::mask()

protected MaskPattern|null $maskPattern = null

$matrix

the actual matrix data array

protected array<string|int, mixed> $matrix

$moduleCount

the size (side length) of the matrix, including quiet zone (if created)

protected int $moduleCount

Methods

__construct()

QRMatrix constructor.

public __construct(int $dimension) : mixed
Parameters
$dimension : int
Tags
noinspection

PhpMissingParentConstructorInspection

Return values
mixed —

check()

Checks whether a module is true (dark) or false (light)

public check(int $x, int $y) : bool

true => $value & 0x800 === 0x800 false => $value & 0x800 === 0

Parameters
$x : int
$y : int
Return values
bool —

checkType()

Checks whether a module is of the given $M_TYPE

public checkType(int $x, int $y, int $M_TYPE) : bool

true => $value & $M_TYPE === $M_TYPE

Parameters
$x : int
$y : int
$M_TYPE : int
Return values
bool —

checkTypes()

checks whether a module matches one of the given $M_TYPES

public checkTypes(int $x, int $y, array<string|int, mixed> $M_TYPES) : bool
Parameters
$x : int
$y : int
$M_TYPES : array<string|int, mixed>
Return values
bool —

flip()

Flips the value of the module

public flip(int $x, int $y) : self
Parameters
$x : int
$y : int
Return values
self —

get()

Returns the value of the module at position [$x, $y]

public get(int $x, int $y) : int
Parameters
$x : int
$y : int
Return values
int —

initFunctionalPatterns()

shortcut to initialize the functional patterns

public initFunctionalPatterns() : self
Return values
self —

mask()

Applies/reverses the mask pattern

public mask() : self

ISO/IEC 18004:2000 Section 8.8.1

Return values
self —

matrix()

Returns the data matrix, returns a pure boolean representation if $boolean is set to true

public matrix([bool $boolean = false ]) : array<string|int, array<string|int, int>>|array<string|int, array<string|int, bool>>
Parameters
$boolean : bool = false
Return values
array<string|int, array<string|int, int>>|array<string|int, array<string|int, bool>> —

mirror()

Mirror the bit matrix in order to attempt a second reading.

public mirror() : self
Return values
self —

readCodewords()

Reads the bits in the BitMatrix representing the finder pattern in the correct order in order to reconstruct the codewords bytes contained within the QR Code.

public readCodewords() : array<string|int, mixed>
Tags
throws
QRCodeDecoderException

if the exact number of bytes expected is not read

Return values
array<string|int, mixed> —

bytes encoded within the QR Code

set()

Sets the $M_TYPE value for the module at position [$x, $y]

public set(int $x, int $y, bool $value, int $M_TYPE) : self

true => $M_TYPE | 0x800 false => $M_TYPE

Parameters
$x : int
$y : int
$value : bool
$M_TYPE : int
Return values
self —

setAlignmentPattern()

Draws the 5x5 alignment patterns

public setAlignmentPattern() : self

ISO/IEC 18004:2000 Section 7.3.5

Return values
self —

setDarkModule()

Sets the "dark module", that is always on the same position 1x1px away from the bottom left finder

public setDarkModule() : self

4 * version + 9 or moduleCount - 8

Return values
self —

setFinderPattern()

Draws the 7x7 finder patterns in the corners top left/right and bottom left

public setFinderPattern() : self

ISO/IEC 18004:2000 Section 7.3.2

Return values
self —

setFormatInfo()

Draws the format info along the finder patterns

public setFormatInfo() : self

ISO/IEC 18004:2000 Section 8.9

Return values
self —

setLogoSpace()

Clears a space of $width * $height in order to add a logo or text.

public setLogoSpace(int $width, int $height[, int $startX = null ][, int $startY = null ]) : self
Parameters
$width : int
$height : int
$startX : int = null
$startY : int = null
Tags
codeCoverageIgnore
throws
QRCodeDataException
Return values
self —

setMirror()

Prepare the parser for a mirrored operation.

public setMirror(bool $mirror) : self

This flag has effect only on the readFormatInformation() and the readVersion() methods. Before proceeding with readCodewords() the mirror() method should be called.

Parameters
$mirror : bool

Whether to read version and format information mirrored.

Return values
self —

setQuietZone()

Draws the "quiet zone" of $size around the matrix

public setQuietZone([int $size = null ]) : self
Parameters
$size : int = null
Tags
codeCoverageIgnore
throws
QRCodeDataException
Return values
self —

setSeparators()

Draws the separator lines around the finder patterns

public setSeparators() : self

ISO/IEC 18004:2000 Section 7.3.3

Return values
self —

setTimingPattern()

Draws the timing pattern (h/v checkered line between the finder patterns)

public setTimingPattern() : self

ISO/IEC 18004:2000 Section 7.3.4

Return values
self —

setVersionNumber()

Draws the version information, 2x 3x6 pixel

public setVersionNumber() : self

ISO/IEC 18004:2000 Section 8.10

Return values
self —

size()

Returns the absoulute size of the matrix, including quiet zone (after setting it).

public size() : int

size = version * 4 + 17 [ + 2 * quietzone size]

Return values
int —

writeCodewords()

Maps the interleaved binary $data on the matrix

public writeCodewords(BitBuffer $bitBuffer) : self
Parameters
$bitBuffer : BitBuffer
Return values
self —

copyVersionBit()

private copyVersionBit(int $i, int $j, int $versionBits) : int
Parameters
$i : int
$j : int
$versionBits : int
Return values
int —

decodeVersionInformation()

private decodeVersionInformation(int $versionBits) : Version|null
Parameters
$versionBits : int
Return values
Version|null —

doDecodeFormatInformation()

private doDecodeFormatInformation(int $maskedFormatInfo1, int $maskedFormatInfo2) : int|null
Parameters
$maskedFormatInfo1 : int

format info indicator, with mask still applied

$maskedFormatInfo2 : int

second copy of same info; both are checked at the same time to establish best match

Return values
int|null —

information about the format it specifies, or null if doesn't seem to match any known pattern

numBitsDiffering()

private numBitsDiffering(int $a, int $b) : int
Parameters
$a : int
$b : int
Return values
int —

readFormatInformation()

Reads format information from one of its two locations within the QR Code.

private readFormatInformation() : self
Tags
throws
QRCodeDecoderException

if both format information locations cannot be parsed as the valid encoding of format information

Return values
self —

readVersion()

Reads version information from one of its two locations within the QR Code.

private readVersion() : self
Tags
throws
QRCodeDecoderException

if both version information locations cannot be parsed as the valid encoding of version information

noinspection

DuplicatedCode

Return values
self —

uRShift()

private uRShift(int $a, int $b) : int
Parameters
$a : int
$b : int
Return values
int —

Search results