PDF417.java (zxing-zxing-3.4.1) | : | PDF417.java (zxing-zxing-3.5.0) | ||
---|---|---|---|---|
skipping to change at line 646 | skipping to change at line 646 | |||
} | } | |||
} | } | |||
} | } | |||
/** | /** | |||
* @param msg message to encode | * @param msg message to encode | |||
* @param errorCorrectionLevel PDF417 error correction level to use | * @param errorCorrectionLevel PDF417 error correction level to use | |||
* @throws WriterException if the contents cannot be encoded in this format | * @throws WriterException if the contents cannot be encoded in this format | |||
*/ | */ | |||
public void generateBarcodeLogic(String msg, int errorCorrectionLevel) throws WriterException { | public void generateBarcodeLogic(String msg, int errorCorrectionLevel) throws WriterException { | |||
generateBarcodeLogic(msg, errorCorrectionLevel, false); | ||||
} | ||||
/** | ||||
* @param msg message to encode | ||||
* @param errorCorrectionLevel PDF417 error correction level to use | ||||
* @param autoECI automatically insert ECIs if needed | ||||
* @throws WriterException if the contents cannot be encoded in this format | ||||
*/ | ||||
public void generateBarcodeLogic(String msg, int errorCorrectionLevel, boolean | ||||
autoECI) throws WriterException { | ||||
//1. step: High-level encoding | //1. step: High-level encoding | |||
int errorCorrectionCodeWords = PDF417ErrorCorrection.getErrorCorrectionCodew ordCount(errorCorrectionLevel); | int errorCorrectionCodeWords = PDF417ErrorCorrection.getErrorCorrectionCodew ordCount(errorCorrectionLevel); | |||
String highLevel = PDF417HighLevelEncoder.encodeHighLevel(msg, compaction, e ncoding); | String highLevel = PDF417HighLevelEncoder.encodeHighLevel(msg, compaction, e ncoding, autoECI); | |||
int sourceCodeWords = highLevel.length(); | int sourceCodeWords = highLevel.length(); | |||
int[] dimension = determineDimensions(sourceCodeWords, errorCorrectionCodeWo rds); | int[] dimension = determineDimensions(sourceCodeWords, errorCorrectionCodeWo rds); | |||
int cols = dimension[0]; | int cols = dimension[0]; | |||
int rows = dimension[1]; | int rows = dimension[1]; | |||
int pad = getNumberOfPadCodewords(sourceCodeWords, errorCorrectionCodeWords, cols, rows); | int pad = getNumberOfPadCodewords(sourceCodeWords, errorCorrectionCodeWords, cols, rows); | |||
//2. step: construct data codewords | //2. step: construct data codewords | |||
skipping to change at line 716 | skipping to change at line 726 | |||
// ignore if previous ratio is closer to preferred ratio | // ignore if previous ratio is closer to preferred ratio | |||
if (dimension != null && Math.abs(newRatio - PREFERRED_RATIO) > Math.abs(r atio - PREFERRED_RATIO)) { | if (dimension != null && Math.abs(newRatio - PREFERRED_RATIO) > Math.abs(r atio - PREFERRED_RATIO)) { | |||
continue; | continue; | |||
} | } | |||
ratio = newRatio; | ratio = newRatio; | |||
dimension = new int[] {cols, rows}; | dimension = new int[] {cols, rows}; | |||
} | } | |||
// Handle case when min values were larger than necessary | // Handle case when min values were larger than necessary | |||
if (dimension == null) { | if (dimension == null) { | |||
int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWord | int rows = calculateNumberOfRows(sourceCodeWords, errorCorrectionCodeWords | |||
s, minCols); | , minCols); | |||
if (rows < minRows) { | if (rows < minRows) { | |||
dimension = new int[]{minCols, minRows}; | dimension = new int[]{minCols, minRows}; | |||
} | } | |||
} | } | |||
if (dimension == null) { | if (dimension == null) { | |||
throw new WriterException("Unable to fit message in columns"); | throw new WriterException("Unable to fit message in columns"); | |||
} | } | |||
return dimension; | return dimension; | |||
} | } | |||
/** | /** | |||
* Sets max/min row/col values | * Sets max/min row/col values | |||
End of changes. 3 change blocks. | ||||
9 lines changed or deleted | 20 lines changed or added |