|
|
|
@ -238,32 +238,32 @@ public final class QrCode {
|
|
|
|
|
* error correction level, data codeword bytes, and mask number.
|
|
|
|
|
* <p>This is a low-level API that most users should not use directly. A mid-level
|
|
|
|
|
* API is the {@link #encodeSegments(List,Ecc,int,int,int,boolean)} function.</p>
|
|
|
|
|
* @param ver the version number to use, which must be in the range 1 to 40 (inclusive)
|
|
|
|
|
* @param ecl the error correction level to use
|
|
|
|
|
* @param version the version number to use, which must be in the range 1 to 40 (inclusive)
|
|
|
|
|
* @param errorCorrectionLevel the error correction level to use
|
|
|
|
|
* @param dataCodewords the bytes representing segments to encode (without ECC)
|
|
|
|
|
* @param msk the mask pattern to use, which is either −1 for automatic choice or from 0 to 7 for fixed choice
|
|
|
|
|
* @param mask the mask pattern to use, which is either −1 for automatic choice or from 0 to 7 for fixed choice
|
|
|
|
|
* @throws NullPointerException if the byte array or error correction level is {@code null}
|
|
|
|
|
* @throws IllegalArgumentException if the version or mask value is out of range,
|
|
|
|
|
* or if the data is the wrong length for the specified version and error correction level
|
|
|
|
|
*/
|
|
|
|
|
public QrCode(int ver, Ecc ecl, byte[] dataCodewords, int msk) {
|
|
|
|
|
public QrCode(int version, Ecc errorCorrectionLevel, byte[] dataCodewords, int mask) {
|
|
|
|
|
// Check arguments and initialize fields
|
|
|
|
|
if (ver < MIN_VERSION || ver > MAX_VERSION)
|
|
|
|
|
if (version < MIN_VERSION || version > MAX_VERSION)
|
|
|
|
|
throw new IllegalArgumentException("Version value out of range");
|
|
|
|
|
if (msk < -1 || msk > 7)
|
|
|
|
|
if (mask < -1 || mask > 7)
|
|
|
|
|
throw new IllegalArgumentException("Mask value out of range");
|
|
|
|
|
version = ver;
|
|
|
|
|
size = ver * 4 + 17;
|
|
|
|
|
errorCorrectionLevel = Objects.requireNonNull(ecl);
|
|
|
|
|
this.version = version;
|
|
|
|
|
this.size = version * 4 + 17;
|
|
|
|
|
this.errorCorrectionLevel = Objects.requireNonNull(errorCorrectionLevel);
|
|
|
|
|
Objects.requireNonNull(dataCodewords);
|
|
|
|
|
modules = new boolean[size][size]; // Initially all white
|
|
|
|
|
isFunction = new boolean[size][size];
|
|
|
|
|
this.modules = new boolean[size][size]; // Initially all white
|
|
|
|
|
this.isFunction = new boolean[size][size];
|
|
|
|
|
|
|
|
|
|
// Compute ECC, draw modules, do masking
|
|
|
|
|
drawFunctionPatterns();
|
|
|
|
|
byte[] allCodewords = addEccAndInterleave(dataCodewords);
|
|
|
|
|
drawCodewords(allCodewords);
|
|
|
|
|
this.mask = handleConstructorMasking(msk);
|
|
|
|
|
this.mask = handleConstructorMasking(mask);
|
|
|
|
|
isFunction = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|