qrtools 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +6 -0
- data/Manifest.txt +65 -0
- data/README.txt +75 -0
- data/Rakefile +49 -0
- data/bin/qrdecode +14 -0
- data/ext/qrtools/Makefile.in +65 -0
- data/ext/qrtools/bitstream.cpp +147 -0
- data/ext/qrtools/bitstream.h +48 -0
- data/ext/qrtools/codedata.cpp +506 -0
- data/ext/qrtools/codedata.h +95 -0
- data/ext/qrtools/container.cpp +288 -0
- data/ext/qrtools/container.h +175 -0
- data/ext/qrtools/decodeqr.h +286 -0
- data/ext/qrtools/ecidecoder.cpp +341 -0
- data/ext/qrtools/ecidecoder.h +110 -0
- data/ext/qrtools/extconf.rb +24 -0
- data/ext/qrtools/formatinfo.cpp +195 -0
- data/ext/qrtools/formatinfo.h +113 -0
- data/ext/qrtools/galois.cpp +593 -0
- data/ext/qrtools/galois.h +134 -0
- data/ext/qrtools/imagereader.cpp +1099 -0
- data/ext/qrtools/imagereader.h +127 -0
- data/ext/qrtools/libdecodeqr.cpp +195 -0
- data/ext/qrtools/libdecodeqr.dep +80 -0
- data/ext/qrtools/libdecodeqr.dsp +160 -0
- data/ext/qrtools/libdecodeqr.dsw +29 -0
- data/ext/qrtools/libdecodeqr.mak +245 -0
- data/ext/qrtools/qrerror.h +40 -0
- data/ext/qrtools/qrtools.c +17 -0
- data/ext/qrtools/qrtools.h +21 -0
- data/ext/qrtools/qrtools_decoder.c +123 -0
- data/ext/qrtools/qrtools_decoder.h +10 -0
- data/ext/qrtools/qrtools_encoder.c +63 -0
- data/ext/qrtools/qrtools_encoder.h +10 -0
- data/ext/qrtools/qrtools_header.c +51 -0
- data/ext/qrtools/qrtools_header.h +10 -0
- data/ext/qrtools/qrtools_image.c +80 -0
- data/ext/qrtools/qrtools_image.h +11 -0
- data/ext/qrtools/qrtools_qrcode.c +36 -0
- data/ext/qrtools/qrtools_qrcode.h +10 -0
- data/ext/qrtools/qrtools_ui_camera.c +58 -0
- data/ext/qrtools/qrtools_ui_camera.h +10 -0
- data/ext/qrtools/qrtools_ui_window.c +40 -0
- data/ext/qrtools/qrtools_ui_window.h +10 -0
- data/ext/qrtools/qrtypes.h +42 -0
- data/ext/qrtools/version.h +42 -0
- data/lib/qrtools.rb +11 -0
- data/lib/qrtools/decoder.rb +17 -0
- data/lib/qrtools/encoder.rb +14 -0
- data/lib/qrtools/image.rb +43 -0
- data/lib/qrtools/qrcode.rb +54 -0
- data/lib/qrtools/ui/camera.rb +28 -0
- data/lib/qrtools/ui/window.rb +16 -0
- data/lib/qrtools/version.rb +3 -0
- data/qrtools.gemspec +38 -0
- data/test/assets/01-1.jpg +0 -0
- data/test/helper.rb +17 -0
- data/test/test_decoder.rb +67 -0
- data/test/test_encoder.rb +35 -0
- data/test/test_header.rb +14 -0
- data/test/test_image.rb +19 -0
- data/test/test_qrcode.rb +78 -0
- data/test/test_qrdecode.rb +0 -0
- data/test/ui/test_camera.rb +43 -0
- data/test/ui/test_window.rb +34 -0
- metadata +138 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/////////////////////////////////////////////////////////////////////////
|
|
2
|
+
//
|
|
3
|
+
// codedata.h --a part of libdecodeqr
|
|
4
|
+
//
|
|
5
|
+
// Copyright(C) 2007 NISHI Takao <zophos@koka-in.org>
|
|
6
|
+
// JMA (Japan Medical Association)
|
|
7
|
+
// NaCl (Network Applied Communication Laboratory Ltd.)
|
|
8
|
+
//
|
|
9
|
+
// This is free software with ABSOLUTELY NO WARRANTY.
|
|
10
|
+
// You can redistribute and/or modify it under the terms of LGPL.
|
|
11
|
+
//
|
|
12
|
+
// $Id: codedata.h 36 2007-02-21 23:22:03Z zophos $
|
|
13
|
+
//
|
|
14
|
+
#ifndef __QR_CODE_DATA__
|
|
15
|
+
#define __QR_CODE_DATA__
|
|
16
|
+
|
|
17
|
+
#include <memory.h>
|
|
18
|
+
#include "galois.h"
|
|
19
|
+
#include "bitstream.h"
|
|
20
|
+
#include "ecidecoder.h"
|
|
21
|
+
#include "qrerror.h"
|
|
22
|
+
|
|
23
|
+
#ifndef NULL
|
|
24
|
+
#define NULL 0
|
|
25
|
+
#endif
|
|
26
|
+
|
|
27
|
+
#define QR_CODE_DATA_GX 0x11d //G(x)=x^8+x^4+x^3+x^2+1
|
|
28
|
+
|
|
29
|
+
namespace Qr{
|
|
30
|
+
class CodeBlock{
|
|
31
|
+
public:
|
|
32
|
+
int total_words;
|
|
33
|
+
int data_words;
|
|
34
|
+
int capability;
|
|
35
|
+
unsigned char *data;
|
|
36
|
+
short status;
|
|
37
|
+
|
|
38
|
+
private:
|
|
39
|
+
int _size;
|
|
40
|
+
Galois::Field *_gf;
|
|
41
|
+
|
|
42
|
+
public:
|
|
43
|
+
CodeBlock(int total_words,int data_words,int capability,
|
|
44
|
+
Galois::Field *gf);
|
|
45
|
+
~CodeBlock();
|
|
46
|
+
|
|
47
|
+
void clear();
|
|
48
|
+
unsigned char *push(unsigned char data);
|
|
49
|
+
bool has_vacant_data();
|
|
50
|
+
|
|
51
|
+
int error_correct();
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
class CodeData{
|
|
55
|
+
public:
|
|
56
|
+
int version;
|
|
57
|
+
int level;
|
|
58
|
+
|
|
59
|
+
int total_words; // total words (data+ecc)
|
|
60
|
+
int data_words; // number of data words
|
|
61
|
+
int data_blocks; // number of rs_block
|
|
62
|
+
CodeBlock **data;
|
|
63
|
+
|
|
64
|
+
int length; // number of decoded charactors
|
|
65
|
+
int byte_length;
|
|
66
|
+
|
|
67
|
+
short status;
|
|
68
|
+
private:
|
|
69
|
+
Galois::Field *_gf;
|
|
70
|
+
|
|
71
|
+
int _size;
|
|
72
|
+
int _index;
|
|
73
|
+
|
|
74
|
+
unsigned char *_raw_data;
|
|
75
|
+
|
|
76
|
+
public:
|
|
77
|
+
CodeData(int version,int level);
|
|
78
|
+
~CodeData();
|
|
79
|
+
|
|
80
|
+
void clear();
|
|
81
|
+
unsigned char *push(unsigned char data);
|
|
82
|
+
|
|
83
|
+
unsigned char *dump();
|
|
84
|
+
unsigned char *dump_block(int index);
|
|
85
|
+
unsigned char *dump_data();
|
|
86
|
+
unsigned char *raw_data();
|
|
87
|
+
|
|
88
|
+
int decode();
|
|
89
|
+
|
|
90
|
+
private:
|
|
91
|
+
int _error_correct();
|
|
92
|
+
};
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
#endif
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/////////////////////////////////////////////////////////////////////////
|
|
2
|
+
//
|
|
3
|
+
// container.cpp --a part of libdecodeqr
|
|
4
|
+
//
|
|
5
|
+
// Copyright(C) 2007 NISHI Takao <zophos@koka-in.org>
|
|
6
|
+
// JMA (Japan Medical Association)
|
|
7
|
+
// NaCl (Network Applied Communication Laboratory Ltd.)
|
|
8
|
+
//
|
|
9
|
+
// This is free software with ABSOLUTELY NO WARRANTY.
|
|
10
|
+
// You can redistribute and/or modify it under the terms of LGPL.
|
|
11
|
+
//
|
|
12
|
+
// $Id: container.cpp 36 2007-02-21 23:22:03Z zophos $
|
|
13
|
+
//
|
|
14
|
+
#include "container.h"
|
|
15
|
+
|
|
16
|
+
namespace Qr{
|
|
17
|
+
|
|
18
|
+
Qr::Qr()
|
|
19
|
+
{
|
|
20
|
+
this->model=2;
|
|
21
|
+
this->version=0;
|
|
22
|
+
this->cells_par_side=0;
|
|
23
|
+
|
|
24
|
+
this->formatinfo=new FormatInfo();
|
|
25
|
+
this->codedata=NULL;
|
|
26
|
+
|
|
27
|
+
this->status=0;
|
|
28
|
+
}
|
|
29
|
+
Qr::~Qr()
|
|
30
|
+
{
|
|
31
|
+
if(this->codedata)
|
|
32
|
+
delete this->codedata;
|
|
33
|
+
|
|
34
|
+
delete this->formatinfo;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
int Qr::set_version(int v)
|
|
38
|
+
{
|
|
39
|
+
if(v<1||v>40){
|
|
40
|
+
this->status|=QR_VERSIONINFO_INVALID;
|
|
41
|
+
throw(0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
this->version=v;
|
|
45
|
+
this->cells_par_side=this->version*4+17;
|
|
46
|
+
return(this->version);
|
|
47
|
+
}
|
|
48
|
+
int Qr::decode_version(unsigned char *data)
|
|
49
|
+
{
|
|
50
|
+
// FIXME
|
|
51
|
+
return(this->version);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
int Qr::decode_formatinfo(unsigned short data)
|
|
55
|
+
{
|
|
56
|
+
this->status&=(~QR_FORMATINFO_ERROR);
|
|
57
|
+
|
|
58
|
+
int ret=this->formatinfo->decode_formatinfo(data);
|
|
59
|
+
this->status|=this->formatinfo->status;
|
|
60
|
+
|
|
61
|
+
if(this->codedata)
|
|
62
|
+
delete this->codedata;
|
|
63
|
+
|
|
64
|
+
this->codedata=new CodeData(this->version,this->formatinfo->level);
|
|
65
|
+
|
|
66
|
+
return(ret);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
Qr *Qr::init_each_finder_pattern_pixel()
|
|
70
|
+
{
|
|
71
|
+
this->_finder_c=0;
|
|
72
|
+
return(this);
|
|
73
|
+
}
|
|
74
|
+
Qr *Qr::init_each_timing_pattern_pixel()
|
|
75
|
+
{
|
|
76
|
+
this->_timing_c=0;
|
|
77
|
+
return(this);
|
|
78
|
+
}
|
|
79
|
+
Qr *Qr::init_each_alignment_pattern_pixel()
|
|
80
|
+
{
|
|
81
|
+
this->_alignment_x=2;
|
|
82
|
+
this->_alignment_y=1;
|
|
83
|
+
this->_alignment_i=-2;
|
|
84
|
+
this->_alignment_j=-2;
|
|
85
|
+
return(this);
|
|
86
|
+
}
|
|
87
|
+
Qr *Qr::init_each_version_pattern_pixel()
|
|
88
|
+
{
|
|
89
|
+
this->_version_c=0;
|
|
90
|
+
return(this);
|
|
91
|
+
}
|
|
92
|
+
Qr *Qr::init_each_formatinfo_pattern_pixel()
|
|
93
|
+
{
|
|
94
|
+
this->formatinfo->init_each_pattern_pixel();
|
|
95
|
+
return(this);
|
|
96
|
+
}
|
|
97
|
+
Qr *Qr::init_each_function_pattern_pixel()
|
|
98
|
+
{
|
|
99
|
+
this->init_each_finder_pattern_pixel();
|
|
100
|
+
this->init_each_timing_pattern_pixel();
|
|
101
|
+
this->init_each_alignment_pattern_pixel();
|
|
102
|
+
this->init_each_version_pattern_pixel();
|
|
103
|
+
this->init_each_formatinfo_pattern_pixel();
|
|
104
|
+
return(this);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
Qr *Qr::each_finder_pattern_pixel(int *x,int *y)
|
|
108
|
+
{
|
|
109
|
+
int c=this->_finder_c;
|
|
110
|
+
|
|
111
|
+
//
|
|
112
|
+
// 8x8x3 pixels
|
|
113
|
+
//
|
|
114
|
+
if(this->_finder_c<64){
|
|
115
|
+
*x=c%8;
|
|
116
|
+
*y=c/8;
|
|
117
|
+
}
|
|
118
|
+
else if(this->_finder_c<128){
|
|
119
|
+
c-=64;
|
|
120
|
+
*x=this->cells_par_side-8+c%8;
|
|
121
|
+
*y=c/8;
|
|
122
|
+
}
|
|
123
|
+
else if(this->_finder_c<192){
|
|
124
|
+
c-=128;
|
|
125
|
+
*x=c%8;
|
|
126
|
+
*y=this->cells_par_side-8+c/8;
|
|
127
|
+
}
|
|
128
|
+
else
|
|
129
|
+
return(NULL);
|
|
130
|
+
|
|
131
|
+
this->_finder_c++;
|
|
132
|
+
return(this);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
Qr *Qr::each_timing_pattern_pixel(int *x,int *y)
|
|
136
|
+
{
|
|
137
|
+
if(this->_timing_c<this->cells_par_side){
|
|
138
|
+
*x=6;
|
|
139
|
+
*y=this->_timing_c;
|
|
140
|
+
}
|
|
141
|
+
else if(this->_timing_c<this->cells_par_side*2){
|
|
142
|
+
*x=this->_timing_c-this->cells_par_side;
|
|
143
|
+
*y=6;
|
|
144
|
+
}
|
|
145
|
+
else
|
|
146
|
+
return(NULL);
|
|
147
|
+
|
|
148
|
+
this->_timing_c++;
|
|
149
|
+
return(this);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
Qr *Qr::each_alignment_pattern_pixel(int *x,int *y)
|
|
153
|
+
{
|
|
154
|
+
int c=alignment_pattern_addr[this->version][0]+1;
|
|
155
|
+
|
|
156
|
+
if((this->_alignment_y==1)&&(this->_alignment_x>=c-1)){
|
|
157
|
+
this->_alignment_y++;
|
|
158
|
+
if(this->_alignment_y==1||this->_alignment_y==c-1)
|
|
159
|
+
this->_alignment_x=2;
|
|
160
|
+
else
|
|
161
|
+
this->_alignment_x=1;
|
|
162
|
+
}
|
|
163
|
+
if(this->_alignment_y>=c)
|
|
164
|
+
return(NULL);
|
|
165
|
+
|
|
166
|
+
*x=alignment_pattern_addr[version][this->_alignment_x]+
|
|
167
|
+
this->_alignment_j;
|
|
168
|
+
*y=alignment_pattern_addr[version][this->_alignment_y]+
|
|
169
|
+
this->_alignment_i;
|
|
170
|
+
|
|
171
|
+
this->_alignment_j++;
|
|
172
|
+
if(this->_alignment_j>2){
|
|
173
|
+
this->_alignment_j=-2;
|
|
174
|
+
this->_alignment_i++;
|
|
175
|
+
|
|
176
|
+
if(this->_alignment_i>2){
|
|
177
|
+
this->_alignment_i=-2;
|
|
178
|
+
this->_alignment_x++;
|
|
179
|
+
|
|
180
|
+
if((this->_alignment_x>=c)||
|
|
181
|
+
((this->_alignment_y==1)&&(this->_alignment_x>=c-1))){
|
|
182
|
+
this->_alignment_y++;
|
|
183
|
+
if(this->_alignment_y==1||this->_alignment_y==c-1)
|
|
184
|
+
this->_alignment_x=2;
|
|
185
|
+
else
|
|
186
|
+
this->_alignment_x=1;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return(this);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
Qr *Qr::each_version_pattern_pixel(int *x,int *y)
|
|
195
|
+
{
|
|
196
|
+
if(this->version<7)
|
|
197
|
+
return(NULL);
|
|
198
|
+
|
|
199
|
+
if(this->_version_c<18){
|
|
200
|
+
*x=version_info_addr[0][this->_version_c][0];
|
|
201
|
+
*y=version_info_addr[0][this->_version_c][1];
|
|
202
|
+
}
|
|
203
|
+
else if(this->_version_c<36){
|
|
204
|
+
*x=version_info_addr[1][this->_version_c-18][0];
|
|
205
|
+
*y=version_info_addr[1][this->_version_c-18][1];
|
|
206
|
+
}
|
|
207
|
+
else
|
|
208
|
+
return(NULL);
|
|
209
|
+
|
|
210
|
+
if(*x<0)
|
|
211
|
+
*x+=this->cells_par_side;
|
|
212
|
+
if(*y<0)
|
|
213
|
+
*y+=this->cells_par_side;
|
|
214
|
+
this->_version_c++;
|
|
215
|
+
return(this);
|
|
216
|
+
}
|
|
217
|
+
Qr *Qr::each_version_pattern_pixel(int pos,int *x,int *y)
|
|
218
|
+
{
|
|
219
|
+
if(this->version<7)
|
|
220
|
+
return(NULL);
|
|
221
|
+
|
|
222
|
+
if(this->_version_c<18){
|
|
223
|
+
*x=version_info_addr[pos][this->_version_c][0];
|
|
224
|
+
*y=version_info_addr[pos][this->_version_c][1];
|
|
225
|
+
}
|
|
226
|
+
else
|
|
227
|
+
return(NULL);
|
|
228
|
+
|
|
229
|
+
if(*x<0)
|
|
230
|
+
*x+=this->cells_par_side;
|
|
231
|
+
if(*y<0)
|
|
232
|
+
*y+=this->cells_par_side;
|
|
233
|
+
this->_version_c++;
|
|
234
|
+
return(this);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
Qr *Qr::each_formatinfo_pattern_pixel(int *x,int *y)
|
|
238
|
+
{
|
|
239
|
+
if(this->formatinfo->each_pattern_pixel(x,y)){
|
|
240
|
+
if(*x<0)
|
|
241
|
+
*x+=this->cells_par_side;
|
|
242
|
+
if(*y<0)
|
|
243
|
+
*y+=this->cells_par_side;
|
|
244
|
+
return(this);
|
|
245
|
+
}
|
|
246
|
+
else
|
|
247
|
+
return(NULL);
|
|
248
|
+
}
|
|
249
|
+
Qr *Qr::each_formatinfo_pattern_pixel(int pos,int *x,int *y)
|
|
250
|
+
{
|
|
251
|
+
if(this->formatinfo->each_pattern_pixel(pos,x,y)){
|
|
252
|
+
if(*x<0)
|
|
253
|
+
*x+=this->cells_par_side;
|
|
254
|
+
if(*y<0)
|
|
255
|
+
*y+=this->cells_par_side;
|
|
256
|
+
return(this);
|
|
257
|
+
}
|
|
258
|
+
else
|
|
259
|
+
return(NULL);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
Qr *Qr::each_function_pattern_pixel(int *x,int *y)
|
|
263
|
+
{
|
|
264
|
+
if(this->each_finder_pattern_pixel(x,y))
|
|
265
|
+
return(this);
|
|
266
|
+
if(this->each_timing_pattern_pixel(x,y))
|
|
267
|
+
return(this);
|
|
268
|
+
if(this->each_alignment_pattern_pixel(x,y))
|
|
269
|
+
return(this);
|
|
270
|
+
if(this->each_version_pattern_pixel(x,y))
|
|
271
|
+
return(this);
|
|
272
|
+
return(this->each_formatinfo_pattern_pixel(x,y));
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
unsigned char *Qr::push_codedata(unsigned char data)
|
|
276
|
+
{
|
|
277
|
+
return(this->codedata->push(data));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
int Qr::decode_codedata()
|
|
282
|
+
{
|
|
283
|
+
int ret=this->codedata->decode();
|
|
284
|
+
this->status|=this->codedata->status;
|
|
285
|
+
|
|
286
|
+
return(ret);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/////////////////////////////////////////////////////////////////////////
|
|
2
|
+
//
|
|
3
|
+
// container.h --a part of libdecodeqr
|
|
4
|
+
//
|
|
5
|
+
// Copyright(C) 2007 NISHI Takao <zophos@koka-in.org>
|
|
6
|
+
// JMA (Japan Medical Association)
|
|
7
|
+
// NaCl (Network Applied Communication Laboratory Ltd.)
|
|
8
|
+
//
|
|
9
|
+
// This is free software with ABSOLUTELY NO WARRANTY.
|
|
10
|
+
// You can redistribute and/or modify it under the terms of LGPL.
|
|
11
|
+
//
|
|
12
|
+
// $Id: container.h 36 2007-02-21 23:22:03Z zophos $
|
|
13
|
+
//
|
|
14
|
+
#ifndef __QR_CONTAINER__
|
|
15
|
+
#define __QR_CONTAINER__
|
|
16
|
+
|
|
17
|
+
#include "qrerror.h"
|
|
18
|
+
#include "formatinfo.h"
|
|
19
|
+
#include "codedata.h"
|
|
20
|
+
|
|
21
|
+
#ifndef NULL
|
|
22
|
+
#define NULL 0
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
#define QR_VERSION_INFO_GX 0x1f25 // G(x)=x^12+x^11+x^10+x^9+x^8+x^5+x^2+1
|
|
26
|
+
#define QR_VERSION_INFO_DATA_SIZE 18
|
|
27
|
+
|
|
28
|
+
namespace Qr{
|
|
29
|
+
//
|
|
30
|
+
// alignment pattern center coordinates
|
|
31
|
+
// ( from JISX0510(2004) Appendix E Table.1 p.71)
|
|
32
|
+
//
|
|
33
|
+
// {{number of data without me,coord_1,...coord_n},...}
|
|
34
|
+
//
|
|
35
|
+
// number of alignment pattern = (number of data)^2 - 3
|
|
36
|
+
//
|
|
37
|
+
const int alignment_pattern_addr[41][8]={
|
|
38
|
+
// version 0 (not exist, just a dummy)
|
|
39
|
+
{0,0,0,0,0,0,0,0},
|
|
40
|
+
|
|
41
|
+
// version 1
|
|
42
|
+
{0,0,0,0,0,0,0,0},
|
|
43
|
+
{2,6,18,0,0,0,0,0},
|
|
44
|
+
{2,6,22,0,0,0,0,0},
|
|
45
|
+
{2,6,26,0,0,0,0,0},
|
|
46
|
+
|
|
47
|
+
{2,6,30,0,0,0,0,0},
|
|
48
|
+
{2,6,34,0,0,0,0,0},
|
|
49
|
+
{3,6,22,38,0,0,0,0},
|
|
50
|
+
{3,6,24,42,0,0,0,0},
|
|
51
|
+
{3,6,26,46,0,0,0,0},
|
|
52
|
+
|
|
53
|
+
// version 10
|
|
54
|
+
{3,6,28,50,0,0,0,0},
|
|
55
|
+
{3,6,30,54,0,0,0,0},
|
|
56
|
+
{3,6,32,58,0,0,0,0},
|
|
57
|
+
{3,6,34,62,0,0,0,0},
|
|
58
|
+
{4,6,26,46,66,0,0,0},
|
|
59
|
+
|
|
60
|
+
{4,6,26,48,70,0,0,0},
|
|
61
|
+
{4,6,26,50,74,0,0,0},
|
|
62
|
+
{4,6,30,54,78,0,0,0},
|
|
63
|
+
{4,6,30,56,82,0,0,0},
|
|
64
|
+
{4,6,30,58,86,0,0,0},
|
|
65
|
+
|
|
66
|
+
// version 20
|
|
67
|
+
{4,6,34,62,90,0,0,0},
|
|
68
|
+
{5,6,28,50,72,94,0,0},
|
|
69
|
+
{5,6,26,50,74,98,0,0},
|
|
70
|
+
{5,6,30,54,78,102,0,0},
|
|
71
|
+
{5,6,28,54,80,106,0,0},
|
|
72
|
+
|
|
73
|
+
{5,6,32,58,84,110,0,0},
|
|
74
|
+
{5,6,30,58,86,114,0,0},
|
|
75
|
+
{5,6,34,62,90,118,0,0},
|
|
76
|
+
{6,6,26,50,74,98,122,0},
|
|
77
|
+
{6,6,30,54,78,102,126,0},
|
|
78
|
+
|
|
79
|
+
// version 30
|
|
80
|
+
{6,6,26,52,78,104,130,0},
|
|
81
|
+
{6,6,30,56,82,108,134,0},
|
|
82
|
+
{6,6,34,60,86,112,138,0},
|
|
83
|
+
{6,6,30,58,96,114,142,0},
|
|
84
|
+
{6,6,34,62,90,118,146,0},
|
|
85
|
+
|
|
86
|
+
{7,6,30,54,78,102,126,150},
|
|
87
|
+
{7,6,24,50,76,102,128,154},
|
|
88
|
+
{7,6,28,54,80,106,132,158},
|
|
89
|
+
{7,6,32,58,84,110,136,162},
|
|
90
|
+
{7,6,26,54,82,110,138,166},
|
|
91
|
+
|
|
92
|
+
// version 40
|
|
93
|
+
{7,6,30,58,86,114,142,170}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
//
|
|
97
|
+
// version info;
|
|
98
|
+
// array of {x,y}; minus value means SymbolLength - Value;
|
|
99
|
+
// e.g; symbol size = 21 x 21, values {1,-1} points {1,20} module
|
|
100
|
+
//
|
|
101
|
+
const int version_info_addr[2][18][2]={
|
|
102
|
+
{
|
|
103
|
+
{-11,0},{-10,0},{-9,0},
|
|
104
|
+
{-11,1},{-10,1},{-9,1},
|
|
105
|
+
{-11,2},{-10,2},{-9,2},
|
|
106
|
+
{-11,3},{-10,3},{-9,3},
|
|
107
|
+
{-11,4},{-10,4},{-9,4},
|
|
108
|
+
{-11,5},{-10,5},{-9,5}
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
{0,-11},{0,-10},{0,-9},
|
|
112
|
+
{1,-11},{1,-10},{1,-9},
|
|
113
|
+
{2,-11},{2,-10},{2,-9},
|
|
114
|
+
{3,-11},{3,-10},{3,-9},
|
|
115
|
+
{4,-11},{4,-10},{4,-9},
|
|
116
|
+
{5,-11},{5,-10},{5,-9}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
class Qr{
|
|
121
|
+
public:
|
|
122
|
+
int model;
|
|
123
|
+
int version;
|
|
124
|
+
int cells_par_side;
|
|
125
|
+
|
|
126
|
+
//int finder_pattern;
|
|
127
|
+
//int timing_pattern;
|
|
128
|
+
//int alignment_pattern;
|
|
129
|
+
|
|
130
|
+
short status;
|
|
131
|
+
|
|
132
|
+
FormatInfo *formatinfo;
|
|
133
|
+
CodeData *codedata;
|
|
134
|
+
|
|
135
|
+
private:
|
|
136
|
+
int _finder_c;
|
|
137
|
+
int _timing_c;
|
|
138
|
+
int _alignment_x;
|
|
139
|
+
int _alignment_y;
|
|
140
|
+
int _alignment_i;
|
|
141
|
+
int _alignment_j;
|
|
142
|
+
int _version_c;
|
|
143
|
+
|
|
144
|
+
public:
|
|
145
|
+
Qr();
|
|
146
|
+
~Qr();
|
|
147
|
+
|
|
148
|
+
int set_version(int v);
|
|
149
|
+
int decode_version(unsigned char *data); //FIXME
|
|
150
|
+
|
|
151
|
+
int decode_formatinfo(unsigned short data);
|
|
152
|
+
|
|
153
|
+
Qr *init_each_finder_pattern_pixel();
|
|
154
|
+
Qr *init_each_timing_pattern_pixel();
|
|
155
|
+
Qr *init_each_alignment_pattern_pixel();
|
|
156
|
+
Qr *init_each_version_pattern_pixel();
|
|
157
|
+
Qr *init_each_formatinfo_pattern_pixel();
|
|
158
|
+
Qr *init_each_function_pattern_pixel();
|
|
159
|
+
|
|
160
|
+
Qr *each_finder_pattern_pixel(int *x,int *y);
|
|
161
|
+
Qr *each_timing_pattern_pixel(int *x,int *y);
|
|
162
|
+
Qr *each_alignment_pattern_pixel(int *x,int *y);
|
|
163
|
+
Qr *each_version_pattern_pixel(int *x,int *y);
|
|
164
|
+
Qr *each_version_pattern_pixel(int pos,int *x,int *y);
|
|
165
|
+
Qr *each_formatinfo_pattern_pixel(int *x,int *y);
|
|
166
|
+
Qr *each_formatinfo_pattern_pixel(int pos,int *x,int *y);
|
|
167
|
+
Qr *each_function_pattern_pixel(int *x,int *y);
|
|
168
|
+
|
|
169
|
+
unsigned char *push_codedata(unsigned char data);
|
|
170
|
+
int decode_codedata();
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
#endif
|