Class QRCode


  • public class QRCode
    extends java.lang.Object
    This class provides generation of QR code that can represent BINARY, NUMERICAL and ALPHANUMERICAL data. See the example bellow:
         Image image = new QRCode.generate("John Doe");
     
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static boolean DEBUG  
      static int ECC_HIGH
      This variable represents high level error correction
      static int ECC_LOW
      This variable represents low level error correction
      static int ECC_MEDIUM
      This variable represents medium level error correction
      static int ECC_QUARTILE
      This variable represents quartile level error correction
    • Constructor Summary

      Constructors 
      Constructor Description
      QRCode()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static int getBestVersion​(java.lang.String text, int errorCorrection)  
      byte[][] getBytes​(java.lang.String text)
      This method returns the byte matrix that contains the values of each point of the QRCode.
      byte[][] getBytes​(java.lang.String text, int errorCorrection)
      This method returns the byte matrix that contains the values of each point of the QRCode.
      byte[][] getBytes​(java.lang.String text, int errorCorrection, int version)
      This method returns the byte matrix that contains the values of each point of the QRCode.
      Image getImage​(java.lang.String text)
      This method returns an totalcross.ui.Image instance that contains the values of each point of the QRCode.
      Image getImage​(java.lang.String text, int ecc)
      This method returns an totalcross.ui.Image instance that contains the values of each point of the QRCode.
      Image getImage​(java.lang.String text, int ecc, int version)
      This method returns an totalcross.ui.Image instance that contains the values of each point of the QRCode.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • ECC_LOW

        public static final int ECC_LOW
        This variable represents low level error correction
        See Also:
        Constant Field Values
      • ECC_MEDIUM

        public static final int ECC_MEDIUM
        This variable represents medium level error correction
        See Also:
        Constant Field Values
      • ECC_QUARTILE

        public static final int ECC_QUARTILE
        This variable represents quartile level error correction
        See Also:
        Constant Field Values
      • ECC_HIGH

        public static final int ECC_HIGH
        This variable represents high level error correction
        See Also:
        Constant Field Values
      • DEBUG

        public static boolean DEBUG
    • Constructor Detail

      • QRCode

        public QRCode()
    • Method Detail

      • getBytes

        public byte[][] getBytes​(java.lang.String text,
                                 int errorCorrection,
                                 int version)
        This method returns the byte matrix that contains the values of each point of the QRCode. A QR code is composed of many little squares, called modules, which represent encoded data, with additional error correction (allowing partially damaged QR codes to still be read). Blank modules are 0x00 and black modules are 0xFF.
        Parameters:
        version - The version of a QR code is a number between 1 and 40 (inclusive), which indicates the size of the QR code. The width and height of a QR code are always equal (it is square) and are equal to 4 * version + 17.
        errorCorrection - The level of error correction is a number between 0 and 3 (inclusive), or can be one of the symbolic names ECC_LOW, ECC_MEDIUM, ECC_QUARTILE and ECC_HIGH. Higher levels of error correction sacrifice data capacity, but allow a larger portion of the QR code to be damaged or unreadable.
        text - The text to encode.
      • getBytes

        public byte[][] getBytes​(java.lang.String text,
                                 int errorCorrection)
        This method returns the byte matrix that contains the values of each point of the QRCode. A QR code is composed of many little squares, called modules, which represent encoded data, with additional error correction (allowing partially damaged QR codes to still be read). Blank modules are 0x00 and black modules are 0xFF.

        This method do some calculus to find the best version considering ecc and the given text

        Parameters:
        errorCorrection - The level of error correction is a number between 0 and 3 (inclusive), or can be one of the symbolic names ECC_LOW, ECC_MEDIUM, ECC_QUARTILE and ECC_HIGH. Higher levels of error correction sacrifice data capacity, but allow a larger portion of the QR code to be damaged or unreadable.
        text - The text to encode.
      • getBytes

        public byte[][] getBytes​(java.lang.String text)
        This method returns the byte matrix that contains the values of each point of the QRCode. A QR code is composed of many little squares, called modules, which represent encoded data, with additional error correction (allowing partially damaged QR codes to still be read). Blank modules are 0x00 and black modules are 0xFF.

        This method do some calculus to find the best version considering ecc and the given text.

        By default this method uses ECC_QUARTILE as default ecc.

        Parameters:
        text - The text to encode.
      • getImage

        public Image getImage​(java.lang.String text,
                              int ecc,
                              int version)
                       throws ImageException
        This method returns an totalcross.ui.Image instance that contains the values of each point of the QRCode. A QR code is composed of many little squares, called modules, which represent encoded data, with additional error correction (allowing partially damaged QR codes to still be read). Blank modules are 0x00 and black modules are 0xFF.
        Parameters:
        text - The text to encode.
        Throws:
        ImageException
      • getImage

        public Image getImage​(java.lang.String text,
                              int ecc)
                       throws ImageException
        This method returns an totalcross.ui.Image instance that contains the values of each point of the QRCode. A QR code is composed of many little squares, called modules, which represent encoded data, with additional error correction (allowing partially damaged QR codes to still be read). Blank modules are 0x00 and black modules are 0xFF.

        This method do some calculus to find the best version considering ecc and the given text.

        Parameters:
        text - The text to encode.
        ecc - The correction level.
        Throws:
        ImageException
      • getImage

        public Image getImage​(java.lang.String text)
                       throws ImageException
        This method returns an totalcross.ui.Image instance that contains the values of each point of the QRCode. A QR code is composed of many little squares, called modules, which represent encoded data, with additional error correction (allowing partially damaged QR codes to still be read). Blank modules are 0x00 and black modules are 0xFF.

        This method do some calculus to find the best version considering ecc and the given text.

        By default this method uses ECC_QUARTILE as default ecc.

        Parameters:
        text - The text to encode.
        Throws:
        ImageException
      • getBestVersion

        public static int getBestVersion​(java.lang.String text,
                                         int errorCorrection)