java.lang.Object
com.google.zxing.qrcode.encoder.ByteMatrix
JAVAPORT: The original code was a 2D array of ints, but since it only ever gets assigned -1, 0, and 1, I'm going to use less memory and go with bytes.
Field Summary
Constructor Summary
ConstructorsConstructorDescriptionByteMatrix(int width, int height) Creates a new ByteMatrix with the specified dimensions.Method Summary
All MethodsModifier and TypeMethodDescriptionvoidclear(byte value) Clears all cells in the matrix to the specified value.byteget(int x, int y) Gets the value at the specified coordinates.byte[][]getArray()Returns the internal representation as bytes, in row-major order.intReturns the height of the matrix.intgetWidth()Returns the width of the matrix.voidset(int x, int y, boolean value) Sets the value at the specified coordinates using a boolean value.voidset(int x, int y, byte value) Sets the value at the specified coordinates.voidset(int x, int y, int value) Sets the value at the specified coordinates using an int value.toString()Matrix as text for debugging.
Field Details
bytes
private final byte[][] bytesinternal 2D array of byteswidth
private final int widthwidth of the matrixheight
private final int heightheight of the matrix
Constructor Details
ByteMatrix
public ByteMatrix(int width, int height) Creates a new ByteMatrix with the specified dimensions.- Parameters:
width- the width of the matrixheight- the height of the matrix
Method Details
getHeight
public int getHeight()Returns the height of the matrix.- Returns:
- the height of the matrix
getWidth
public int getWidth()Returns the width of the matrix.- Returns:
- the width of the matrix
get
public byte get(int x, int y) Gets the value at the specified coordinates.- Parameters:
x- the x coordinatey- the y coordinate- Returns:
- the byte value at the specified position
getArray
public byte[][] getArray()Returns the internal representation as bytes, in row-major order.- Returns:
- an internal representation as bytes, in row-major order. array[y][x] represents point (x,y)
set
public void set(int x, int y, byte value) Sets the value at the specified coordinates.- Parameters:
x- the x coordinatey- the y coordinatevalue- the byte value to set
set
public void set(int x, int y, int value) Sets the value at the specified coordinates using an int value.- Parameters:
x- the x coordinatey- the y coordinatevalue- the int value to set (will be cast to byte)
set
public void set(int x, int y, boolean value) Sets the value at the specified coordinates using a boolean value.- Parameters:
x- the x coordinatey- the y coordinatevalue- the boolean value to set (true = 1, false = 0)
clear
public void clear(byte value) Clears all cells in the matrix to the specified value.- Parameters:
value- the byte value to set all cells to
toString