mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-21 10:45:12 -04: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
1 changed files with 13 additions and 3 deletions
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…
Add table
Add a link
Reference in a new issue