forked from swex/QR-Image-embedded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
QR_Encode.h
95 lines (64 loc) · 2.41 KB
/
QR_Encode.h
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
84
85
86
87
88
89
90
91
92
93
94
95
/*
* QR_Encode.h
*
* Created on: Jan 18, 2012
* Author: swex
*/
// Constant
// Error correction level
#define QR_LEVEL_L 0
#define QR_LEVEL_M 1
#define QR_LEVEL_Q 2
#define QR_LEVEL_H 3
//Data Mode
#define QR_MODE_NUMERAL 0
#define QR_MODE_ALPHABET 1
#define QR_MODE_8BIT 2
#define QR_MODE_KANJI 3
//Group version (model number)
#define QR_VERSION_S 0 // 1 ~ 9
#define QR_VERSION_M 1 // 10 ~ 26
#define QR_VERSION_L 2 // 27 ~ 40
#define MAX_ALLCODEWORD 3706 //The maximum total number of code words
#define MAX_DATACODEWORD 2956 //Maximum data word code (version 40-L)
#define MAX_CODEBLOCK 153 //(Including RS code word) the maximum number of block data code word
#define MAX_MODULESIZE 177 //Maximum number of modules in a side
#define MAX_BITDATA 3917 // finfile data
//Margin when drawing a bitmap
//#define QR_MARGIN 4
/////////////////////////////////////////////////////////////////////////////
typedef struct tagRS_BLOCKINFO
{
int ncRSBlock; //RS block number
int ncAllCodeWord; //The number of codewords in the block
int ncDataCodeWord; //The number of data code words (the number of code words - the number of RS code word)
} RS_BLOCKINFO, *LPRS_BLOCKINFO;
/////////////////////////////////////////////////////////////////////////////
//Version code-related information (model number)
typedef struct tagQR_VERSIONINFO
{
int nVersionNo;
int ncAllCodeWord;
// Error correction levels (0 = L, 1 = M, 2 = Q, 3 = H)
int ncDataCodeWord[4]; // data len
int ncAlignPoint; // position
int nAlignPoint[6]; // numberof
RS_BLOCKINFO RS_BlockInfo1[4]; // EC pos
RS_BLOCKINFO RS_BlockInfo2[4]; // EC pos
} QR_VERSIONINFO, *LPQR_VERSIONINFO;
typedef unsigned short WORD;
typedef unsigned char BYTE;
typedef BYTE* LPBYTE;
typedef const char* LPCSTR;
int EncodeData(int nLevel, int nVersion , LPCSTR lpsSource, int sourcelen,unsigned char QR_m_data[]);
/*nLevel - уровень коррекции ошибок
#define QR_LEVEL_L 0
#define QR_LEVEL_M 1
#define QR_LEVEL_Q 2
#define QR_LEVEL_H 3
nVersion - версия кода 1 - 40 разрешение итд 0 - автоопределение исходя из размера
lpsSource - данные на вход
sourcelen - длинна строки 0 - автоопределение, strlen \0 оборвет.
QR_m_data - массив для записи, пишет в биты.
функция возвращает сторону квадрата.
*/