Class QrCode
java.lang.Object
com.codename1.qrcode.QrCode
A QR code, generated from text or bytes: the module grid, and SVG for a
page. The class is shared with the backend, which has no images: a client
draws one with QrCodeImage, a server serves toSvg().
A device shows one so a phone can pair with it -- the address and a one-time token in a URL -- and a server puts one on an enrolment page:
QrCode code = QrCode.encode("https://10.0.0.5:8443/pair?t=4F9A2C", QrCode.ECC_MEDIUM);
Image image = QrCodeImage.create(code, 8);
Byte mode with UTF-8 text, versions 1 to 40, the four standard error correction levels and the mask with the lowest penalty (ISO/IEC 18004). The smallest version that holds the data is chosen.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intRecovers about 30%, for a code printed where it gets scuffed.static final intRecovers about 7% of the code.static final intRecovers about 15%; the usual choice.static final intRecovers about 25%. -
Method Summary
Modifier and TypeMethodDescriptionstatic QrCodeencode(byte[] data, int ecc) Encodes bytes.static QrCodeEncodes text as UTF-8.intintgetMask()The mask pattern chosen, 0 to 7.intgetSize()Modules per side,17 + 4 * version, without the quiet zone.intThe version, 1 to 40.booleanisDark(int x, int y) True for a dark module; false outside the grid, which is the quiet zone.toSvg()The code as an SVG document, one unit per module with a four module quiet zone, for a web page or a printed label.
-
Field Details
-
ECC_LOW
public static final int ECC_LOWRecovers about 7% of the code.- See Also:
-
ECC_MEDIUM
public static final int ECC_MEDIUMRecovers about 15%; the usual choice.- See Also:
-
ECC_QUARTILE
public static final int ECC_QUARTILERecovers about 25%.- See Also:
-
ECC_HIGH
public static final int ECC_HIGHRecovers about 30%, for a code printed where it gets scuffed.- See Also:
-
-
Method Details
-
encode
-
encode
-
getSize
public int getSize()Modules per side,17 + 4 * version, without the quiet zone. -
getVersion
public int getVersion()The version, 1 to 40. -
getErrorCorrection
-
getMask
public int getMask()The mask pattern chosen, 0 to 7. -
isDark
public boolean isDark(int x, int y) True for a dark module; false outside the grid, which is the quiet zone. -
toSvg
The code as an SVG document, one unit per module with a four module quiet zone, for a web page or a printed label.
-