-
Notifications
You must be signed in to change notification settings - Fork 32
/
qrenc.c
62 lines (54 loc) · 1.11 KB
/
qrenc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "qrencode.h"
int main(int argc, char **argv)
{
int x, y;
int ret;
x = 1;
if( argc > 2 )
x = atoi(argv[2]);
y = 6;
if( argc > 1 )
y = atoi(argv[1]);
y = initecc(x,y);
// if size is known, pick frame,
//iiteccsize( ecc, strlen(s) );
ret = fread(strinbuf, 1, y, stdin);
strinbuf[ret] = '\0';
initframe();
qrencode();
/* data */
#ifdef PAD
printf("P1\n%d %d\n", WD + 8, WD + 8);
for (y = 0; y < 4; y++) {
for (x = 0; x < WD + 8; x++)
printf("0 ");
printf("\n");
}
#else
printf("P1\n%d %d\n", WD, WD);
#endif
for (y = 0; y < WD; y++) {
#ifdef PAD
for (x = 0; x < 4; x++)
printf("0 ");
#endif
for (x = 0; x < WD; x++)
printf("%d ", QRBIT(x,y) );
#ifdef PAD
for (x = 0; x < 4; x++)
printf("0 ");
#endif
printf("\n");
}
#ifdef PAD
for (y = 0; y < 4; y++) {
for (x = 0; x < WD + 8; x++)
printf("0 ");
printf("\n");
}
#endif
return 0;
}