kazuhikoarase / qrcode-generator

QR Code Generator implementation in JavaScript, Java and more.
https://kazuhikoarase.github.io/qrcode-generator/js/demo/
MIT License
2.12k stars 680 forks source link

Generated QRCode has errors #1

Closed jfs closed 11 years ago

jfs commented 11 years ago

Current code does not generate error free QR codes. Fortunately the errors are fixed by ReedSolomon, resulting in a still working QR code. The error is traced back to the following line, in the 'mapdata' function:

if  (col  ==  6)  col--;

This code is needed to skip the timing pattern column (col 6). But all columns <= 6 need to shift when filling the map data. Replacing the line with the following results in error free QR codes:

if (col <= 6) col--;

Thanks.

kazuhikoarase commented 11 years ago

Hi,

It seems working correctly.

for (var col = even_number_ge_20; col > 0; col -= 2) {
  if (col == 6) col -= 1;
  // fill col, col - 1
}

If replace col == 6 with col <= 6, it will skip not only column 6 but also 3 and 0.

col == 6 fills: ... 8,7 (6) 5,4 3,2 1,0
col <= 6 fills: ... 8,7 (6) 5,4 (3) 2,1 (0)

Thank you.