void test_struct_semilong(void) { QRcode_List *codes, *list; const char *str = "asdfasdfasdfasdfasdfASDFASDASDFASDFAsdfasdfasdfasdASDFASDFADSADadsfasdf"; int num, size; testStart("Testing semi-long structured-append symbols"); codes = QRcode_encodeString8bitStructured(str, 1, QR_ECLEVEL_L); list = codes; num = 0; while(list != NULL) { num++; assert_equal(list->code->version, 1, "version number is %d (1 expected)\n", list->code->version); list = list->next; } size = QRcode_List_size(codes); assert_equal(num, size, "QRcode_List_size returns wrong size?"); QRcode_List_free(codes); codes = QRcode_encodeStringStructured(str, 1, QR_ECLEVEL_L, QR_MODE_8, 1); list = codes; num = 0; while(list != NULL) { num++; assert_equal(list->code->version, 1, "version number is %d (1 expected)\n", list->code->version); list = list->next; } size = QRcode_List_size(codes); assert_equal(num, size, "QRcode_List_size returns wrong size?"); QRcode_List_free(codes); testFinish(); }
void draw_structuredQRcode(QRinput_Struct *s) { int i, w, h, n, x, y; int swidth; QRcode_List *qrcodes, *p; qrcodes = QRcode_encodeInputStructured(s); if(qrcodes == NULL) return; swidth = (qrcodes->code->width + margin * 2) * size; n = QRcode_List_size(qrcodes); w = (n < 4)?n:4; h = (n - 1) / 4 + 1; screen = SDL_SetVideoMode(swidth * w, swidth * h, 32, 0); SDL_FillRect(screen, NULL, 0xffffff); p = qrcodes; for(i=0; i<n; i++) { x = (i % 4) * swidth; y = (i / 4) * swidth; draw_QRcode(p->code, x, y); p = p->next; } SDL_Flip(screen); QRcode_List_free(qrcodes); }