Class ByteMatrix

java.lang.Object
com.itextpdf.barcodes.qrcode.ByteMatrix

public final class ByteMatrix extends Object
A class which wraps a 2D array of bytes. The default usage is signed. If you want to use it as a unsigned container, it's up to you to do byteValue & 0xff at each location. 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.
Author:
dswitkin@google.com (Daniel Switkin)
  • Constructor Summary

    Constructors
    Constructor
    Description
    ByteMatrix(int width, int height)
    Create a ByteMatix of given width and height, with the values initialized to 0
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    clear(byte value)
    Resets the contents of the entire matrix to value
    byte
    get(int x, int y)
    Get the value of the byte at (x,y)
    byte[][]
     
    int
     
    int
     
    void
    set(int x, int y, byte value)
    Set the value of the byte at (x,y)
    void
    set(int x, int y, int value)
    Set the value of the byte at (x,y)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • ByteMatrix

      public ByteMatrix (int width, int height)
      Create a ByteMatix of given width and height, with the values initialized to 0
      Parameters:
      width - width of the matrix
      height - height of the matrix
  • Method Details

    • getHeight

      public int getHeight()
      Returns:
      height of the matrix
    • getWidth

      public int getWidth()
      Returns:
      width of the matrix
    • get

      public byte get (int x, int y)
      Get the value of the byte at (x,y)
      Parameters:
      x - the width coordinate
      y - the height coordinate
      Returns:
      the byte value at position (x,y)
    • getArray

      public byte[][] getArray()
      Returns:
      matrix as byte[][]
    • set

      public void set (int x, int y, byte value)
      Set the value of the byte at (x,y)
      Parameters:
      x - the width coordinate
      y - the height coordinate
      value - the new byte value
    • set

      public void set (int x, int y, int value)
      Set the value of the byte at (x,y)
      Parameters:
      x - the width coordinate
      y - the height coordinate
      value - the new byte value
    • clear

      public void clear (byte value)
      Resets the contents of the entire matrix to value
      Parameters:
      value - new value of every element
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      String representation