Skip to content

Latest commit

 

History

History
394 lines (150 loc) · 3.37 KB

BitMatrix.md

File metadata and controls

394 lines (150 loc) · 3.37 KB

BitMatrix

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

Properties

width

Width of the bit matrix.

private int $width

height

Height of the bit matrix.

private int $height

rowSize

Size in bits of each individual row.

private int $rowSize

bits

Bits representation.

private \SplFixedArray<int> $bits

Methods

__construct

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

Parameters:

Parameter Type Description
$width int
$height int

get

Gets the requested bit, where true means black.

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

Parameters:

Parameter Type Description
$x int
$y int

set

Sets the given bit to true.

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

Parameters:

Parameter Type Description
$x int
$y int

flip

Flips the given bit.

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

Parameters:

Parameter Type Description
$x int
$y int

clear

Clears all bits (set to false).

public clear(): void

setRegion

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

getRow

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

setRow

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

getEnclosingRectangle

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

public getEnclosingRectangle(): int[]|null

getTopLeftOnBit

Gets the most top left set bit.

public getTopLeftOnBit(): int[]|null

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


getBottomRightOnBit

Gets the most bottom right set bit.

public getBottomRightOnBit(): int[]|null

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


getWidth

Gets the width of the matrix,

public getWidth(): int

getHeight

Gets the height of the matrix.

public getHeight(): int