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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
#include <stdlib.h>
#include <qr/code.h>
#include <qr/bitmap.h>
#include "code-common.h"
void qr_code_destroy(struct qr_code * code)
{
if (code) {
qr_bitmap_destroy(code->modules);
free(code);
}
}
int qr_code_width(const struct qr_code * code)
{
return code->version * 4 + 17;
}
size_t code_total_capacity(int version)
{
int side = version * 4 + 17;
int alignment_side = version > 1 ? (version / 7) + 2 : 0;
int alignment_count = alignment_side >= 2 ?
alignment_side * alignment_side - 3 : 0;
int locator_bits = 8*8*3;
int format_bits = 8*4 - 1 + (version >= 7 ? 6*3*2 : 0);
int timing_bits = 2 * (side - 8*2 -
(alignment_side > 2 ? (alignment_side - 2) * 5 : 0));
int function_bits = timing_bits + format_bits + locator_bits
+ alignment_count * 5*5;
return side * side - function_bits;
}
const int QR_ALIGNMENT_LOCATION[40][7] = {
{ 0, 0, 0, 0, 0, 0, 0 }, /* 1 */
{ 6, 18, 0, 0, 0, 0, 0 }, /* 2 */
{ 6, 22, 0, 0, 0, 0, 0 }, /* 3 */
{ 6, 26, 0, 0, 0, 0, 0 }, /* 4 */
{ 6, 30, 0, 0, 0, 0, 0 }, /* 5 */
{ 6, 34, 0, 0, 0, 0, 0 }, /* 6 */
{ 6, 22, 38, 0, 0, 0, 0 }, /* 7 */
{ 6, 24, 42, 0, 0, 0, 0 }, /* 8 */
{ 6, 26, 46, 0, 0, 0, 0 }, /* 9 */
{ 6, 28, 50, 0, 0, 0, 0 }, /* 10 */
{ 6, 30, 54, 0, 0, 0, 0 }, /* 11 */
{ 6, 32, 58, 0, 0, 0, 0 }, /* 12 */
{ 6, 34, 62, 0, 0, 0, 0 }, /* 13 */
{ 6, 26, 46, 66, 0, 0, 0 }, /* 14 */
{ 6, 26, 48, 70, 0, 0, 0 }, /* 15 */
{ 6, 26, 50, 74, 0, 0, 0 }, /* 16 */
{ 6, 30, 54, 78, 0, 0, 0 }, /* 17 */
{ 6, 30, 56, 82, 0, 0, 0 }, /* 18 */
{ 6, 30, 58, 86, 0, 0, 0 }, /* 19 */
{ 6, 34, 62, 90, 0, 0, 0 }, /* 20 */
{ 6, 28, 50, 72, 94, 0, 0 }, /* 21 */
{ 6, 26, 50, 74, 98, 0, 0 }, /* 22 */
{ 6, 30, 54, 78,102, 0, 0 }, /* 23 */
{ 6, 28, 54, 80,106, 0, 0 }, /* 24 */
{ 6, 32, 58, 84,110, 0, 0 }, /* 25 */
{ 6, 30, 58, 86,114, 0, 0 }, /* 26 */
{ 6, 34, 62, 90,118, 0, 0 }, /* 27 */
{ 6, 26, 50, 74, 98,122, 0 }, /* 28 */
{ 6, 30, 54, 78,102,126, 0 }, /* 29 */
{ 6, 26, 52, 78,104,130, 0 }, /* 30 */
{ 6, 30, 56, 82,108,134, 0 }, /* 31 */
{ 6, 34, 60, 86,112,138, 0 }, /* 32 */
{ 6, 30, 58, 86,114,142, 0 }, /* 33 */
{ 6, 34, 62, 90,118,146, 0 }, /* 34 */
{ 6, 30, 54, 78,102,126,150 }, /* 35 */
{ 6, 24, 50, 76,102,128,154 }, /* 36 */
{ 6, 28, 54, 80,106,132,158 }, /* 37 */
{ 6, 32, 58, 84,110,136,162 }, /* 38 */
{ 6, 26, 54, 82,110,138,166 }, /* 39 */
{ 6, 30, 58, 86,114,142,170 }, /* 40 */
};
|