\BaconQrCode\CommonBitMatrix

Bit matrix.

Represents a 2D matrix of bits. In function arguments below, and throughout the common module, x is the column position, and y is the row position. The ordering is always x, y. The origin is at the top-left.

Summary

Methods
Properties
Constants
__construct()
get()
set()
flip()
clear()
setRegion()
getRow()
setRow()
getEnclosingRectangle()
getTopLeftOnBit()
getBottomRightOnBit()
getWidth()
getHeight()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$width
$height
$rowSize
$bits
N/A

Properties

$width

$width : int

Width of the bit matrix.

Type

int

$height

$height : int

Height of the bit matrix.

Type

int

$rowSize

$rowSize : int

Size in bits of each individual row.

Type

int

$bits

$bits : \SplFixedArray<int>

Bits representation.

Type

SplFixedArray

Methods

__construct()

__construct(int  $width, int  $height = null) : mixed

Parameters

int $width
int $height

Throws

\BaconQrCode\Exception\InvalidArgumentException

if a dimension is smaller than zero

Returns

mixed —

get()

get(int  $x, int  $y) : bool

Gets the requested bit, where true means black.

Parameters

int $x
int $y

Returns

bool —

set()

set(int  $x, int  $y) : void

Sets the given bit to true.

Parameters

int $x
int $y

flip()

flip(int  $x, int  $y) : void

Flips the given bit.

Parameters

int $x
int $y

clear()

clear() : void

Clears all bits (set to false).

setRegion()

setRegion(int  $left, int  $top, int  $width, int  $height) : void

Sets a square region of the bit matrix to true.

Parameters

int $left
int $top
int $width
int $height

Throws

\BaconQrCode\Exception\InvalidArgumentException

if left or top are negative

\BaconQrCode\Exception\InvalidArgumentException

if width or height are smaller than 1

\BaconQrCode\Exception\InvalidArgumentException

if region does not fit into the matix

getRow()

getRow(int  $y, \BaconQrCode\Common\BitArray  $row = null) : \BaconQrCode\Common\BitArray

A fast method to retrieve one row of data from the matrix as a BitArray.

Parameters

int $y
\BaconQrCode\Common\BitArray $row

Returns

\BaconQrCode\Common\BitArray —

setRow()

setRow(int  $y, \BaconQrCode\Common\BitArray  $row) : void

Sets a row of data from a BitArray.

Parameters

int $y
\BaconQrCode\Common\BitArray $row

getEnclosingRectangle()

getEnclosingRectangle() : int[]|null

This is useful in detecting the enclosing rectangle of a 'pure' barcode.

Returns

int[]|null —

getTopLeftOnBit()

getTopLeftOnBit() : int[]|null

Gets the most top left set bit.

This is useful in detecting a corner of a 'pure' barcode.

Returns

int[]|null —

getBottomRightOnBit()

getBottomRightOnBit() : int[]|null

Gets the most bottom right set bit.

This is useful in detecting a corner of a 'pure' barcode.

Returns

int[]|null —

getWidth()

getWidth() : int

Gets the width of the matrix,

Returns

int —

getHeight()

getHeight() : int

Gets the height of the matrix.

Returns

int —