mirror of
https://github.com/zint/zint
synced 2024-11-16 20:57:25 +13:00
Allocate more memory for percentages in Alphanumeric mode in QR Code
Fixes #104 reported by Daniel Gredler <sdanig@users.sourceforge.net>
This commit is contained in:
parent
91d933adb7
commit
04b08eb39c
16
backend/qr.c
16
backend/qr.c
@ -1319,6 +1319,8 @@ static int getBinaryLength(const int version,char inputMode[],const int inputDat
|
|||||||
char currentMode;
|
char currentMode;
|
||||||
int j;
|
int j;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int alphalength;
|
||||||
|
int percent = 0;
|
||||||
|
|
||||||
applyOptimisation(version, inputMode, inputLength);
|
applyOptimisation(version, inputMode, inputLength);
|
||||||
|
|
||||||
@ -1352,12 +1354,20 @@ static int getBinaryLength(const int version,char inputMode[],const int inputDat
|
|||||||
break;
|
break;
|
||||||
case 'A':
|
case 'A':
|
||||||
count += tribus(version, 9, 11, 13);
|
count += tribus(version, 9, 11, 13);
|
||||||
switch (blockLength(i, inputMode, inputLength) % 2) {
|
alphalength = blockLength(i, inputMode, inputLength);
|
||||||
|
// In alphanumeric mode % becomes %%
|
||||||
|
for (j = i; j < (i + alphalength); j++) {
|
||||||
|
if (inputData[j] == '%') {
|
||||||
|
percent++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
alphalength += percent;
|
||||||
|
switch (alphalength % 2) {
|
||||||
case 0:
|
case 0:
|
||||||
count += (blockLength(i, inputMode, inputLength) / 2) * 11;
|
count += (alphalength / 2) * 11;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
count += ((blockLength(i, inputMode, inputLength) - 1) / 2) * 11;
|
count += ((alphalength - 1) / 2) * 11;
|
||||||
count += 6;
|
count += 6;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user