new
Dependents: epaper_mbed_test_copy1
QR_Encode.h@0:9efeb5787ae9, 2014-04-08 (annotated)
- Committer:
- fenoth
- Date:
- Tue Apr 08 10:08:03 2014 +0000
- Revision:
- 0:9efeb5787ae9
qr
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
fenoth | 0:9efeb5787ae9 | 1 | /* |
fenoth | 0:9efeb5787ae9 | 2 | * QR_Encode.h |
fenoth | 0:9efeb5787ae9 | 3 | * |
fenoth | 0:9efeb5787ae9 | 4 | * Created on: Jan 18, 2012 |
fenoth | 0:9efeb5787ae9 | 5 | * Author: swex |
fenoth | 0:9efeb5787ae9 | 6 | */ |
fenoth | 0:9efeb5787ae9 | 7 | |
fenoth | 0:9efeb5787ae9 | 8 | #include <string.h> |
fenoth | 0:9efeb5787ae9 | 9 | #include <stdlib.h> |
fenoth | 0:9efeb5787ae9 | 10 | |
fenoth | 0:9efeb5787ae9 | 11 | |
fenoth | 0:9efeb5787ae9 | 12 | // Constant |
fenoth | 0:9efeb5787ae9 | 13 | |
fenoth | 0:9efeb5787ae9 | 14 | // Error correction level |
fenoth | 0:9efeb5787ae9 | 15 | #define QR_LEVEL_L 0 |
fenoth | 0:9efeb5787ae9 | 16 | #define QR_LEVEL_M 1 |
fenoth | 0:9efeb5787ae9 | 17 | #define QR_LEVEL_Q 2 |
fenoth | 0:9efeb5787ae9 | 18 | #define QR_LEVEL_H 3 |
fenoth | 0:9efeb5787ae9 | 19 | |
fenoth | 0:9efeb5787ae9 | 20 | |
fenoth | 0:9efeb5787ae9 | 21 | //Data Mode |
fenoth | 0:9efeb5787ae9 | 22 | #define QR_MODE_NUMERAL 0 |
fenoth | 0:9efeb5787ae9 | 23 | #define QR_MODE_ALPHABET 1 |
fenoth | 0:9efeb5787ae9 | 24 | #define QR_MODE_8BIT 2 |
fenoth | 0:9efeb5787ae9 | 25 | #define QR_MODE_KANJI 3 |
fenoth | 0:9efeb5787ae9 | 26 | |
fenoth | 0:9efeb5787ae9 | 27 | |
fenoth | 0:9efeb5787ae9 | 28 | //Group version (model number) |
fenoth | 0:9efeb5787ae9 | 29 | #define QR_VERSION_S 0 // 1 ~ 9 |
fenoth | 0:9efeb5787ae9 | 30 | #define QR_VERSION_M 1 // 10 ~ 26 |
fenoth | 0:9efeb5787ae9 | 31 | #define QR_VERSION_L 2 // 27 ~ 40 |
fenoth | 0:9efeb5787ae9 | 32 | |
fenoth | 0:9efeb5787ae9 | 33 | #define MAX_ALLCODEWORD 3706 //The maximum total number of code words |
fenoth | 0:9efeb5787ae9 | 34 | #define MAX_DATACODEWORD 2956 //Maximum data word code (version 40-L) |
fenoth | 0:9efeb5787ae9 | 35 | |
fenoth | 0:9efeb5787ae9 | 36 | #define MAX_CODEBLOCK 153 //(Including RS code word) the maximum number of block data code word |
fenoth | 0:9efeb5787ae9 | 37 | #define MAX_MODULESIZE 177 //Maximum number of modules in a side |
fenoth | 0:9efeb5787ae9 | 38 | #define MAX_BITDATA 3917 // finfile data |
fenoth | 0:9efeb5787ae9 | 39 | |
fenoth | 0:9efeb5787ae9 | 40 | //Margin when drawing a bitmap |
fenoth | 0:9efeb5787ae9 | 41 | //#define QR_MARGIN 4 |
fenoth | 0:9efeb5787ae9 | 42 | |
fenoth | 0:9efeb5787ae9 | 43 | |
fenoth | 0:9efeb5787ae9 | 44 | ///////////////////////////////////////////////////////////////////////////// |
fenoth | 0:9efeb5787ae9 | 45 | |
fenoth | 0:9efeb5787ae9 | 46 | typedef struct tagRS_BLOCKINFO |
fenoth | 0:9efeb5787ae9 | 47 | { |
fenoth | 0:9efeb5787ae9 | 48 | int ncRSBlock; //RS block number |
fenoth | 0:9efeb5787ae9 | 49 | int ncAllCodeWord; //The number of codewords in the block |
fenoth | 0:9efeb5787ae9 | 50 | int ncDataCodeWord; //The number of data code words (the number of code words - the number of RS code word) |
fenoth | 0:9efeb5787ae9 | 51 | |
fenoth | 0:9efeb5787ae9 | 52 | } RS_BLOCKINFO, *LPRS_BLOCKINFO; |
fenoth | 0:9efeb5787ae9 | 53 | |
fenoth | 0:9efeb5787ae9 | 54 | |
fenoth | 0:9efeb5787ae9 | 55 | |
fenoth | 0:9efeb5787ae9 | 56 | ///////////////////////////////////////////////////////////////////////////// |
fenoth | 0:9efeb5787ae9 | 57 | //Version code-related information (model number) |
fenoth | 0:9efeb5787ae9 | 58 | |
fenoth | 0:9efeb5787ae9 | 59 | typedef struct tagQR_VERSIONINFO |
fenoth | 0:9efeb5787ae9 | 60 | { |
fenoth | 0:9efeb5787ae9 | 61 | int nVersionNo; |
fenoth | 0:9efeb5787ae9 | 62 | int ncAllCodeWord; |
fenoth | 0:9efeb5787ae9 | 63 | |
fenoth | 0:9efeb5787ae9 | 64 | // Error correction levels (0 = L, 1 = M, 2 = Q, 3 = H) |
fenoth | 0:9efeb5787ae9 | 65 | int ncDataCodeWord[4]; // data len |
fenoth | 0:9efeb5787ae9 | 66 | |
fenoth | 0:9efeb5787ae9 | 67 | int ncAlignPoint; // position |
fenoth | 0:9efeb5787ae9 | 68 | int nAlignPoint[6]; // numberof |
fenoth | 0:9efeb5787ae9 | 69 | |
fenoth | 0:9efeb5787ae9 | 70 | RS_BLOCKINFO RS_BlockInfo1[4]; // EC pos |
fenoth | 0:9efeb5787ae9 | 71 | RS_BLOCKINFO RS_BlockInfo2[4]; // EC pos |
fenoth | 0:9efeb5787ae9 | 72 | |
fenoth | 0:9efeb5787ae9 | 73 | } QR_VERSIONINFO, *LPQR_VERSIONINFO; |
fenoth | 0:9efeb5787ae9 | 74 | |
fenoth | 0:9efeb5787ae9 | 75 | |
fenoth | 0:9efeb5787ae9 | 76 | typedef unsigned short WORD; |
fenoth | 0:9efeb5787ae9 | 77 | |
fenoth | 0:9efeb5787ae9 | 78 | typedef unsigned char BYTE; |
fenoth | 0:9efeb5787ae9 | 79 | |
fenoth | 0:9efeb5787ae9 | 80 | typedef BYTE* LPBYTE; |
fenoth | 0:9efeb5787ae9 | 81 | |
fenoth | 0:9efeb5787ae9 | 82 | typedef const char* LPCSTR; |
fenoth | 0:9efeb5787ae9 | 83 | |
fenoth | 0:9efeb5787ae9 | 84 | #define ZeroMemory(Destination,Length) memset((Destination),0,(Length)) |
fenoth | 0:9efeb5787ae9 | 85 | int EncodeData(int nLevel, int nVersion , LPCSTR lpsSource, int sourcelen,unsigned char QR_m_data[]); |
fenoth | 0:9efeb5787ae9 | 86 | |
fenoth | 0:9efeb5787ae9 | 87 | /*nLevel - уровень коррекции ошибок |
fenoth | 0:9efeb5787ae9 | 88 | #define QR_LEVEL_L 0 |
fenoth | 0:9efeb5787ae9 | 89 | #define QR_LEVEL_M 1 |
fenoth | 0:9efeb5787ae9 | 90 | #define QR_LEVEL_Q 2 |
fenoth | 0:9efeb5787ae9 | 91 | #define QR_LEVEL_H 3 |
fenoth | 0:9efeb5787ae9 | 92 | |
fenoth | 0:9efeb5787ae9 | 93 | nVersion - версия кода 1 - 40 разрешение итд 0 - автоопределение исходя из размера |
fenoth | 0:9efeb5787ae9 | 94 | |
fenoth | 0:9efeb5787ae9 | 95 | lpsSource - данные на вход |
fenoth | 0:9efeb5787ae9 | 96 | sourcelen - длинна строки 0 - автоопределение, strlen \0 оборвет. |
fenoth | 0:9efeb5787ae9 | 97 | QR_m_data - массив для записи, пишет в биты. |
fenoth | 0:9efeb5787ae9 | 98 | |
fenoth | 0:9efeb5787ae9 | 99 | функция возвращает сторону квадрата. |
fenoth | 0:9efeb5787ae9 | 100 | */ |