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); }
int main(int argc, char *argv[]) { int width; QRcode *qrcode; qrcode = QRcode_encodeString("hanwenfang",0,QR_ECLEVEL_H,QR_MODE_8,0); width = (qrcode->width + margin *2) * size; screen = SDL_SetVideoMode(width,width,32,0); //SDL_FillRect(screen,NULL,0xffffff); draw_QRcode(qrcode,0,0); SDL_Flip(screen); QRcode_free(qrcode); SDL_Quit(); exit(0); }
void draw_singleQRcode(QRinput *stream, int mask) { QRcode *qrcode; int width; QRinput_setVersion(stream, version); QRinput_setErrorCorrectionLevel(stream, level); qrcode = QRcode_encodeMask(stream, mask); if(qrcode == NULL) return; version = qrcode->version; width = (qrcode->width + margin * 2) * size; screen = SDL_SetVideoMode(width, width, 32, 0); SDL_FillRect(screen, NULL, 0xffffff); draw_QRcode(qrcode, 0, 0); SDL_Flip(screen); QRcode_free(qrcode); }