BitMatrix class

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.

Internally the bits are represented in a 1-D array of 32-bit ints. However, each row begins with a new int. This is done intentionally so that we can copy out a row into a BitArray very efficiently.

The ordering of bits is row-major. Within each int, the least significant bits are used first, meaning they represent lower x values. This is compatible with BitArray's implementation.

@author Sean Owen @author dswitkin@google.com (Daniel Switkin)

Constructors

BitMatrix(int _width, [int? height])
Creates an empty BitMatrix.

Properties

data Uint32List
no setter
hashCode int
The hash code for this object.
no setteroverride
height int
@return The height of the matrix
no setter
rowSize int
@return The row size of the matrix
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
width int
@return The width of the matrix
no setter

Methods

clear() → void
Clears all bits (sets to false).
clone() BitMatrix
flip([int? x, int? y]) → void
Flips every bit in the matrix.
get(int x, int y) bool
Gets the requested bit, where true means black.
getBottomRightOnBit() List<int>?
getEnclosingRectangle() List<int>?
This is useful in detecting the enclosing rectangle of a 'pure' barcode.
getRow(int y, BitArray? row) BitArray
A fast method to retrieve one row of data from the matrix as a BitArray.
getTopLeftOnBit() List<int>?
This is useful in detecting a corner of a 'pure' barcode.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
rotate(int degrees) → void
Modifies this BitMatrix to represent the same but rotated the given degrees (0, 90, 180, 270)
rotate180() → void
Modifies this BitMatrix to represent the same but rotated 180 degrees
rotate90() → void
Modifies this BitMatrix to represent the same but rotated 90 degrees counterclockwise
set(int x, int y) → void
Sets the given bit to true.
setRegion(int left, int top, int width, int height) → void
Sets a square region of the bit matrix to true.
setRow(int y, BitArray row) → void
@param y row to set @param row BitArray to copy from
toString([String setString = 'X ', String unsetString = ' ', String lineSeparator = '\n']) String
@param setString representation of a set bit @param unsetString representation of an unset bit @param lineSeparator newline character in string representation @return string representation of entire matrix utilizing given strings and line separator
override
unset(int x, int y) → void
xor(BitMatrix mask) → void
Exclusive-or (XOR): Flip the bit in this BitMatrix if the corresponding mask bit is set.

Operators

operator ==(Object other) bool
The equality operator.
override

Static Methods

parse(Object image, [String a = '', String b = '']) BitMatrix
Interprets a 2D array of booleans as a BitMatrix, where "true" means an "on" bit.