|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.zxing.common.BitMatrix
public final class BitMatrix
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.
| Field Summary | ||
|---|---|---|
int[] |
bits
|
|
int |
height
|
|
int |
rowSize
|
|
int |
width
|
|
| Constructor Summary | ||
|---|---|---|
BitMatrix(int dimension)
|
||
BitMatrix(int width,
int height)
|
||
| Method Summary | ||
|---|---|---|
void |
clear()
Clears all bits (sets to false). |
|
void |
flip(int x,
int y)
Flips the given bit. |
|
boolean |
get(int x,
int y)
Gets the requested bit, where true means black. |
|
int |
getDimension()
This method is for compatibility with older code. |
|
int |
getHeight()
|
|
BitArray |
getRow(int y,
BitArray row)
A fast method to retrieve one row of data from the matrix as a BitArray. |
|
int |
getWidth()
|
|
void |
set(int x,
int y)
Sets the given bit to true. |
|
void |
setRegion(int left,
int top,
int width,
int height)
Sets a square region of the bit matrix to true. |
|
String |
toString()
Returns a string representation of the object. |
|
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public final int width
public final int height
public final int rowSize
public final int[] bits
| Constructor Detail |
|---|
public BitMatrix(int dimension)
public BitMatrix(int width,
int height)
| Method Detail |
|---|
public boolean get(int x,
int y)
Gets the requested bit, where true means black.
x - The horizontal component (i.e. which column)y - The vertical component (i.e. which row)
public void set(int x,
int y)
Sets the given bit to true.
x - The horizontal component (i.e. which column)y - The vertical component (i.e. which row)
public void flip(int x,
int y)
Flips the given bit.
x - The horizontal component (i.e. which column)y - The vertical component (i.e. which row)public void clear()
public void setRegion(int left,
int top,
int width,
int height)
Sets a square region of the bit matrix to true.
left - The horizontal position to begin at (inclusive)top - The vertical position to begin at (inclusive)width - The width of the regionheight - The height of the region
public BitArray getRow(int y,
BitArray row)
y - The row to retrieverow - An optional caller-allocated BitArray, will be allocated if null or too small
public int getWidth()
public int getHeight()
public int getDimension()
public String toString()
ObjecttoString method returns a string that
"textually represents" this object. The result should
be a concise but informative representation that is easy for a
person to read.
It is recommended that all subclasses override this method.
The toString method for class Object
returns a string consisting of the name of the class of which the
object is an instance, the at-sign character `@', and
the unsigned hexadecimal representation of the hash code of the
object. In other words, this method returns a string equal to the
value of:
getClass().getName() + '@' + Integer.toHexString(hashCode())
toString in class Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.