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.
- Full name:
\BaconQrCode\Common\BitMatrix
Width of the bit matrix.
private int $width
Height of the bit matrix.
private int $height
Size in bits of each individual row.
private int $rowSize
Bits representation.
private \SplFixedArray<int> $bits
public __construct(int $width, int $height = null): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$width |
int | |
$height |
int |
Gets the requested bit, where true means black.
public get(int $x, int $y): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$x |
int | |
$y |
int |
Sets the given bit to true.
public set(int $x, int $y): void
Parameters:
Parameter | Type | Description |
---|---|---|
$x |
int | |
$y |
int |
Flips the given bit.
public flip(int $x, int $y): void
Parameters:
Parameter | Type | Description |
---|---|---|
$x |
int | |
$y |
int |
Clears all bits (set to false).
public clear(): void
Sets a square region of the bit matrix to true.
public setRegion(int $left, int $top, int $width, int $height): void
Parameters:
Parameter | Type | Description |
---|---|---|
$left |
int | |
$top |
int | |
$width |
int | |
$height |
int |
A fast method to retrieve one row of data from the matrix as a BitArray.
public getRow(int $y, \BaconQrCode\Common\BitArray $row = null): \BaconQrCode\Common\BitArray
Parameters:
Parameter | Type | Description |
---|---|---|
$y |
int | |
$row |
\BaconQrCode\Common\BitArray |
Sets a row of data from a BitArray.
public setRow(int $y, \BaconQrCode\Common\BitArray $row): void
Parameters:
Parameter | Type | Description |
---|---|---|
$y |
int | |
$row |
\BaconQrCode\Common\BitArray |
This is useful in detecting the enclosing rectangle of a 'pure' barcode.
public getEnclosingRectangle(): int[]|null
Gets the most top left set bit.
public getTopLeftOnBit(): int[]|null
This is useful in detecting a corner of a 'pure' barcode.
Gets the most bottom right set bit.
public getBottomRightOnBit(): int[]|null
This is useful in detecting a corner of a 'pure' barcode.
Gets the width of the matrix,
public getWidth(): int
Gets the height of the matrix.
public getHeight(): int