|
|
|
@ -383,8 +383,8 @@ namespace qrcodegen {
|
|
|
|
|
throw "Invalid argument";
|
|
|
|
|
|
|
|
|
|
// Calculate parameter numbers
|
|
|
|
|
let numBlocks: int = QrCode_NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
|
|
|
|
let blockEccLen: int = QrCode_ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];
|
|
|
|
|
let numBlocks: int = QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
|
|
|
|
let blockEccLen: int = QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver];
|
|
|
|
|
let rawCodewords: int = Math.floor(QrCode.getNumRawDataModules(ver) / 8);
|
|
|
|
|
let numShortBlocks: int = numBlocks - rawCodewords % numBlocks;
|
|
|
|
|
let shortBlockLen: int = Math.floor(rawCodewords / numBlocks);
|
|
|
|
@ -604,8 +604,8 @@ namespace qrcodegen {
|
|
|
|
|
if (ver < QrCode.MIN_VERSION || ver > QrCode.MAX_VERSION)
|
|
|
|
|
throw "Version number out of range";
|
|
|
|
|
return Math.floor(QrCode.getNumRawDataModules(ver) / 8) -
|
|
|
|
|
QrCode_ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] *
|
|
|
|
|
QrCode_NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
|
|
|
|
QrCode.ECC_CODEWORDS_PER_BLOCK[ecl.ordinal][ver] *
|
|
|
|
|
QrCode.NUM_ERROR_CORRECTION_BLOCKS[ecl.ordinal][ver];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -621,11 +621,9 @@ namespace qrcodegen {
|
|
|
|
|
private static readonly PENALTY_N3: int = 40;
|
|
|
|
|
private static readonly PENALTY_N4: int = 10;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-- Private tables of constants --*/
|
|
|
|
|
|
|
|
|
|
const QrCode_ECC_CODEWORDS_PER_BLOCK: Array<Array<int>> = [
|
|
|
|
|
private static readonly ECC_CODEWORDS_PER_BLOCK: Array<Array<int>> = [
|
|
|
|
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
|
|
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
|
|
|
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // Low
|
|
|
|
@ -634,7 +632,7 @@ namespace qrcodegen {
|
|
|
|
|
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30], // High
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const QrCode_NUM_ERROR_CORRECTION_BLOCKS: Array<Array<int>> = [
|
|
|
|
|
private static readonly NUM_ERROR_CORRECTION_BLOCKS: Array<Array<int>> = [
|
|
|
|
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
|
|
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
|
|
|
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25], // Low
|
|
|
|
@ -643,6 +641,8 @@ namespace qrcodegen {
|
|
|
|
|
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81], // High
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Returns true iff the i'th bit of x is set to 1.
|
|
|
|
|
function getBit(x: int, i: int): boolean {
|
|
|
|
|