• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Generates QR Codes from text strings and byte arrays.
3  *
4  * <p>This project aims to be the best, clearest QR Code generator library. The primary goals are flexible options and absolute correctness. Secondary goals are compact implementation size and good documentation comments.</p>
5  * <p>Home page for this fast library with design explanation and benchmarks: <a href="https://www.nayuki.io/page/fast-qr-code-generator-library">https://www.nayuki.io/page/fast-qr-code-generator-library</a></p>
6  * <p>Home page for the main project with live JavaScript demo, extensive descriptions, and competitor comparisons: <a href="https://www.nayuki.io/page/qr-code-generator-library">https://www.nayuki.io/page/qr-code-generator-library</a></p>
7  *
8  * <h2>Features</h2>
9  * <p>Core features:</p>
10  * <ul>
11  *   <li><p>Approximately 1.5× to 10× faster than other Java implementation</p></li>
12  *   <li><p>Shorter code but more documentation comments compared to competing libraries</p></li>
13  *   <li><p>Supports encoding all 40 versions (sizes) and all 4 error correction levels, as per the QR Code Model 2 standard</p></li>
14  *   <li><p>Output format: Raw modules/pixels of the QR symbol</p></li>
15  *   <li><p>Detects finder-like penalty patterns more accurately than other implementations</p></li>
16  *   <li><p>Encodes numeric and special-alphanumeric text in less space than general text</p></li>
17  *   <li><p>Encodes Japanese Unicode text in kanji mode to save a lot of space compared to UTF-8 bytes</p></li>
18  *   <li><p>Computes optimal segment mode switching for text with mixed numeric/alphanumeric/general/kanji parts</p></li>
19  *   <li><p>Open-source code under the permissive MIT License</p></li>
20  * </ul>
21  * <p>Manual parameters:</p>
22  * <ul>
23  *   <li><p>User can specify minimum and maximum version numbers allowed, then library will automatically choose smallest version in the range that fits the data</p></li>
24  *   <li><p>User can specify mask pattern manually, otherwise library will automatically evaluate all 8 masks and select the optimal one</p></li>
25  *   <li><p>User can specify absolute error correction level, or allow the library to boost it if it doesn't increase the version number</p></li>
26  *   <li><p>User can create a list of data segments manually and add ECI segments</p></li>
27  * </ul>
28  * <p>More information about QR Code technology and this library's design can be found on the project home page.</p>
29  *
30  * <h2>Examples</h2>
31  * <p>Simple operation:</p>
32  * <pre style="margin-left:2em">import java.awt.image.BufferedImage;
33  *import java.io.File;
34  *import javax.imageio.ImageIO;
35  *import io.nayuki.fastqrcodegen.*;
36  *
37  *QrCode qr = QrCode.encodeText("Hello, world!", QrCode.Ecc.MEDIUM);
38  *BufferedImage img = toImage(qr, 4, 10);  // See QrCodeGeneratorDemo
39  *ImageIO.write(img, "png", new File("qr-code.png"));</pre>
40  * <p>Manual operation:</p>
41  * <pre style="margin-left:2em">import java.util.List;
42  *import io.nayuki.fastqrcodegen.*;
43  *
44  *List&lt;QrSegment&gt; segs = QrSegment.makeSegments("3141592653589793238462643383");
45  *QrCode qr = QrCode.encodeSegments(segs, QrCode.Ecc.HIGH, 5, 5, 2, false);
46  *for (int y = 0; y &lt; qr.size; y++) {
47  *    for (int x = 0; x &lt; qr.size; x++) {
48  *        (... paint qr.getModule(x, y) ...)
49  *    }
50  *}</pre>
51  */
52 package io.nayuki.fastqrcodegen;
53