|
|
@ -128,20 +128,20 @@ public final class QrCode {
|
|
|
|
/*---- Constructor ----*/
|
|
|
|
/*---- Constructor ----*/
|
|
|
|
|
|
|
|
|
|
|
|
public QrCode(int ver, Ecc ecl, byte[] dataCodewords, int mask) {
|
|
|
|
public QrCode(int ver, Ecc ecl, byte[] dataCodewords, int mask) {
|
|
|
|
// Check arguments
|
|
|
|
// Check arguments and initialize fields
|
|
|
|
errorCorrectionLevel = Objects.requireNonNull(ecl);
|
|
|
|
if (ver < MIN_VERSION || ver > MAX_VERSION)
|
|
|
|
if (ver < MIN_VERSION || ver > MAX_VERSION || mask < -1 || mask > 7)
|
|
|
|
throw new IllegalArgumentException("Version value out of range");
|
|
|
|
throw new IllegalArgumentException("Value out of range");
|
|
|
|
if (mask < -1 || mask > 7)
|
|
|
|
Objects.requireNonNull(dataCodewords);
|
|
|
|
throw new IllegalArgumentException("Mask value out of range");
|
|
|
|
|
|
|
|
|
|
|
|
// Initialize fields
|
|
|
|
|
|
|
|
version = ver;
|
|
|
|
version = ver;
|
|
|
|
size = ver * 4 + 17;
|
|
|
|
size = ver * 4 + 17;
|
|
|
|
|
|
|
|
errorCorrectionLevel = Objects.requireNonNull(ecl);
|
|
|
|
|
|
|
|
Objects.requireNonNull(dataCodewords);
|
|
|
|
|
|
|
|
|
|
|
|
QrTemplate tpl = QrTemplate.getInstance(ver);
|
|
|
|
QrTemplate tpl = QrTemplate.getInstance(ver);
|
|
|
|
modules = tpl.template.clone();
|
|
|
|
modules = tpl.template.clone();
|
|
|
|
|
|
|
|
|
|
|
|
// Draw function patterns, draw all codewords, do masking
|
|
|
|
// Compute ECC, draw modules, do masking
|
|
|
|
byte[] allCodewords = addEccAndInterleave(dataCodewords);
|
|
|
|
byte[] allCodewords = addEccAndInterleave(dataCodewords);
|
|
|
|
drawCodewords(tpl.dataOutputBitIndexes, allCodewords);
|
|
|
|
drawCodewords(tpl.dataOutputBitIndexes, allCodewords);
|
|
|
|
this.mask = handleConstructorMasking(tpl.masks, mask);
|
|
|
|
this.mask = handleConstructorMasking(tpl.masks, mask);
|
|
|
|