2013-09-23 5 views
1

Я использую libqrencode.
Я хочу QR-код с версия 1 (21x21) и ECC Level H. Согласно http://www.qrcode.com/en/about/version.html, у меня может быть 17 Numerics. Так что я делаю:Как правильно закодировать числовой QRCode?

QRcode *result; 
QRinput *input = QRinput_new2(1, QR_ECLEVEL_H); 
unsigned char *data = new unsigned char[17]; 
for(int i = 0; i < 17; i++) { 
    data[i] = 0; 
} 

QRinput_append(input, QR_MODE_NUM, 17, data); 

result = QRcode_encodeInput(input); 

int idx = 0; 
printf("%d\n", result->width); 
for(int i = 0; i < result->width; i++) { 
    for(int j = 0; j < result->width; j++) { 
     if(result->data[idx] & 1) { 
      printf("%d", 1); 
     } else { 
      printf("%d", 0); 
     } 
     idx++; 
    } 
    printf("\n"); 
} 

Но whaterver мои данные, моя программа возвращает тот же результат.
Что мне здесь не хватает?

ответ

0

я подам вопрос на GitHub там и получил ответ очень быстро https://github.com/fukuchi/libqrencode/issues/33#issuecomment-24997167
вопрос мои данные инициализации здесь:

unsigned char *data = new unsigned char[17]; 
for(int i = 0; i < 17; i++) { 
    data[i] = 0; 
} 

должно быть:

unsigned char *data = new unsigned char[17]; 
for(int i = 0; i < 17; i++) { 
    data[i] = '0'; //here 
} 
Смежные вопросы