Encoder.java (zxing-zxing-3.4.0) | : | Encoder.java (zxing-zxing-3.4.1) | ||
---|---|---|---|---|
skipping to change at line 104 | skipping to change at line 104 | |||
// Append ECI segment if applicable | // Append ECI segment if applicable | |||
if (mode == Mode.BYTE && hasEncodingHint) { | if (mode == Mode.BYTE && hasEncodingHint) { | |||
CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding); | CharacterSetECI eci = CharacterSetECI.getCharacterSetECIByName(encoding); | |||
if (eci != null) { | if (eci != null) { | |||
appendECI(eci, headerBits); | appendECI(eci, headerBits); | |||
} | } | |||
} | } | |||
// Append the FNC1 mode header for GS1 formatted data if applicable | // Append the FNC1 mode header for GS1 formatted data if applicable | |||
boolean hasGS1FormatHint = hints != null && hints.containsKey(EncodeHintType .GS1_FORMAT); | boolean hasGS1FormatHint = hints != null && hints.containsKey(EncodeHintType .GS1_FORMAT); | |||
if (hasGS1FormatHint && Boolean.valueOf(hints.get(EncodeHintType.GS1_FORMAT) .toString())) { | if (hasGS1FormatHint && Boolean.parseBoolean(hints.get(EncodeHintType.GS1_FO RMAT).toString())) { | |||
// GS1 formatted codes are prefixed with a FNC1 in first position mode hea der | // GS1 formatted codes are prefixed with a FNC1 in first position mode hea der | |||
appendModeInfo(Mode.FNC1_FIRST_POSITION, headerBits); | appendModeInfo(Mode.FNC1_FIRST_POSITION, headerBits); | |||
} | } | |||
// (With ECI in place,) Write the mode marker | // (With ECI in place,) Write the mode marker | |||
appendModeInfo(mode, headerBits); | appendModeInfo(mode, headerBits); | |||
// Collect data within the main segment, separately, to count its size if ne eded. Don't add it to | // Collect data within the main segment, separately, to count its size if ne eded. Don't add it to | |||
// main payload yet. | // main payload yet. | |||
BitArray dataBits = new BitArray(); | BitArray dataBits = new BitArray(); | |||
skipping to change at line 158 | skipping to change at line 158 | |||
QRCode qrCode = new QRCode(); | QRCode qrCode = new QRCode(); | |||
qrCode.setECLevel(ecLevel); | qrCode.setECLevel(ecLevel); | |||
qrCode.setMode(mode); | qrCode.setMode(mode); | |||
qrCode.setVersion(version); | qrCode.setVersion(version); | |||
// Choose the mask pattern and set to "qrCode". | // Choose the mask pattern and set to "qrCode". | |||
int dimension = version.getDimensionForVersion(); | int dimension = version.getDimensionForVersion(); | |||
ByteMatrix matrix = new ByteMatrix(dimension, dimension); | ByteMatrix matrix = new ByteMatrix(dimension, dimension); | |||
int maskPattern = chooseMaskPattern(finalBits, ecLevel, version, matrix); | ||||
// Enable manual selection of the pattern to be used via hint | ||||
int maskPattern = -1; | ||||
if (hints != null && hints.containsKey(EncodeHintType.QR_MASK_PATTERN)) { | ||||
int hintMaskPattern = Integer.parseInt(hints.get(EncodeHintType.QR_MASK_PA | ||||
TTERN).toString()); | ||||
maskPattern = QRCode.isValidMaskPattern(hintMaskPattern) ? hintMaskPattern | ||||
: -1; | ||||
} | ||||
if (maskPattern == -1) { | ||||
maskPattern = chooseMaskPattern(finalBits, ecLevel, version, matrix); | ||||
} | ||||
qrCode.setMaskPattern(maskPattern); | qrCode.setMaskPattern(maskPattern); | |||
// Build the matrix and set it to "qrCode". | // Build the matrix and set it to "qrCode". | |||
MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix); | MatrixUtil.buildMatrix(finalBits, ecLevel, version, maskPattern, matrix); | |||
qrCode.setMatrix(matrix); | qrCode.setMatrix(matrix); | |||
return qrCode; | return qrCode; | |||
} | } | |||
/** | /** | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 14 lines changed or added |