blob: af3a76637dfc26f128425d156b527b0cec56f9e7 (
plain)
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
|
#include <stdlib.h>
#include <qr/bitstream.h>
#include <qr/data.h>
void qr_data_destroy(struct qr_data * data)
{
qr_bitstream_destroy(data->bits);
free(data);
}
size_t qr_data_size_field_length(int version, enum qr_data_type type)
{
static const size_t QR_SIZE_LENGTHS[3][4] = {
{ 10, 9, 8, 8 },
{ 12, 11, 16, 10 },
{ 14, 13, 16, 12 }
};
int row, col;
switch (type) {
case QR_DATA_NUMERIC: col = 0; break;
case QR_DATA_ALPHA: col = 1; break;
case QR_DATA_8BIT: col = 2; break;
case QR_DATA_KANJI: col = 3; break;
default: return 0;
}
if (version < 10)
row = 0;
else if (version < 27)
row = 1;
else
row = 2;
return QR_SIZE_LENGTHS[row][col];
}
|