Documentation

BitMatrix
in package

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.

Table of Contents

$bits  : SplFixedArray<string|int, int>
Bits representation.
$height  : int
Height of the bit matrix.
$rowSize  : int
Size in bits of each individual row.
$width  : int
Width of the bit matrix.
__construct()  : mixed
clear()  : void
Clears all bits (set to false).
flip()  : void
Flips the given bit.
get()  : bool
Gets the requested bit, where true means black.
getBottomRightOnBit()  : array<string|int, int>|null
Gets the most bottom right set bit.
getEnclosingRectangle()  : array<string|int, int>|null
This is useful in detecting the enclosing rectangle of a 'pure' barcode.
getHeight()  : int
Gets the height of the matrix.
getRow()  : BitArray
A fast method to retrieve one row of data from the matrix as a BitArray.
getTopLeftOnBit()  : array<string|int, int>|null
Gets the most top left set bit.
getWidth()  : int
Gets the width of the matrix,
set()  : void
Sets the given bit to true.
setRegion()  : void
Sets a square region of the bit matrix to true.
setRow()  : void
Sets a row of data from a BitArray.

Properties

$bits

Bits representation.

private SplFixedArray<string|int, int> $bits

$height

Height of the bit matrix.

private int $height

$rowSize

Size in bits of each individual row.

private int $rowSize

$width

Width of the bit matrix.

private int $width

Methods

__construct()

public __construct(int $width[, int $height = null ]) : mixed
Parameters
$width : int
$height : int = null
Tags
throws
InvalidArgumentException

if a dimension is smaller than zero

Return values
mixed

clear()

Clears all bits (set to false).

public clear() : void
Return values
void

flip()

Flips the given bit.

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

get()

Gets the requested bit, where true means black.

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

getBottomRightOnBit()

Gets the most bottom right set bit.

public getBottomRightOnBit() : array<string|int, int>|null

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

Return values
array<string|int, int>|null

getEnclosingRectangle()

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

public getEnclosingRectangle() : array<string|int, int>|null
Return values
array<string|int, int>|null

getHeight()

Gets the height of the matrix.

public getHeight() : int
Return values
int

getRow()

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

public getRow(int $y[, BitArray $row = null ]) : BitArray
Parameters
$y : int
$row : BitArray = null
Return values
BitArray

getTopLeftOnBit()

Gets the most top left set bit.

public getTopLeftOnBit() : array<string|int, int>|null

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

Return values
array<string|int, int>|null

getWidth()

Gets the width of the matrix,

public getWidth() : int
Return values
int

set()

Sets the given bit to true.

public set(int $x, int $y) : void
Parameters
$x : int
$y : int
Return values
void

setRegion()

Sets a square region of the bit matrix to true.

public setRegion(int $left, int $top, int $width, int $height) : void
Parameters
$left : int
$top : int
$width : int
$height : int
Tags
throws
InvalidArgumentException

if left or top are negative

throws
InvalidArgumentException

if width or height are smaller than 1

throws
InvalidArgumentException

if region does not fit into the matix

Return values
void

setRow()

Sets a row of data from a BitArray.

public setRow(int $y, BitArray $row) : void
Parameters
$y : int
$row : BitArray
Return values
void

Search results