2009-10-07 08:03:00 +13:00
|
|
|
/* qr.h Data for QR Code */
|
|
|
|
|
|
|
|
/*
|
|
|
|
libzint - the open source barcode library
|
2016-02-21 00:29:19 +13:00
|
|
|
Copyright (C) 2008-2016 Robin Stuart <rstuart114@gmail.com>
|
2009-10-07 08:03:00 +13:00
|
|
|
Copyright (C) 2006 Kentaro Fukuchi <fukuchi@megaui.net>
|
|
|
|
|
2013-05-17 05:26:38 +12:00
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
|
2016-02-21 00:29:19 +13:00
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
2013-05-17 05:26:38 +12:00
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
2016-02-21 00:29:19 +13:00
|
|
|
documentation and/or other materials provided with the distribution.
|
2013-05-17 05:26:38 +12:00
|
|
|
3. Neither the name of the project nor the names of its contributors
|
|
|
|
may be used to endorse or promote products derived from this software
|
2016-02-21 00:29:19 +13:00
|
|
|
without specific prior written permission.
|
2013-05-17 05:26:38 +12:00
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
|
|
|
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
2016-02-21 00:29:19 +13:00
|
|
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
2013-05-17 05:26:38 +12:00
|
|
|
SUCH DAMAGE.
|
2016-02-21 00:29:19 +13:00
|
|
|
*/
|
2009-10-07 08:03:00 +13:00
|
|
|
|
|
|
|
#define LEVEL_L 1
|
|
|
|
#define LEVEL_M 2
|
|
|
|
#define LEVEL_Q 3
|
|
|
|
#define LEVEL_H 4
|
|
|
|
|
|
|
|
#define RHODIUM "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:"
|
|
|
|
|
|
|
|
/* From ISO/IEC 18004:2006 Table 7 */
|
|
|
|
static int qr_data_codewords_L[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
19, 34, 55, 80, 108, 136, 156, 194, 232, 274, 324, 370, 428, 461, 523, 589, 647,
|
|
|
|
721, 795, 861, 932, 1006, 1094, 1174, 1276, 1370, 1468, 1531, 1631,
|
|
|
|
1735, 1843, 1955, 2071, 2191, 2306, 2434, 2566, 2702, 2812, 2956
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_data_codewords_M[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
16, 28, 44, 64, 86, 108, 124, 154, 182, 216, 254, 290, 334, 365, 415, 453, 507,
|
|
|
|
563, 627, 669, 714, 782, 860, 914, 1000, 1062, 1128, 1193, 1267,
|
|
|
|
1373, 1455, 1541, 1631, 1725, 1812, 1914, 1992, 2102, 2216, 2334
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_data_codewords_Q[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
13, 22, 34, 48, 62, 76, 88, 110, 132, 154, 180, 206, 244, 261, 295, 325, 367,
|
|
|
|
397, 445, 485, 512, 568, 614, 664, 718, 754, 808, 871, 911,
|
|
|
|
985, 1033, 1115, 1171, 1231, 1286, 1354, 1426, 1502, 1582, 1666
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_data_codewords_H[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
9, 16, 26, 36, 46, 60, 66, 86, 100, 122, 140, 158, 180, 197, 223, 253, 283,
|
|
|
|
313, 341, 385, 406, 442, 464, 514, 538, 596, 628, 661, 701,
|
|
|
|
745, 793, 845, 901, 961, 986, 1054, 1096, 1142, 1222, 1276
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_total_codewords[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
26, 44, 70, 100, 134, 172, 196, 242, 292, 346, 404, 466, 532, 581, 655, 733, 815,
|
|
|
|
901, 991, 1085, 1156, 1258, 1364, 1474, 1588, 1706, 1828, 1921, 2051,
|
|
|
|
2185, 2323, 2465, 2611, 2761, 2876, 3034, 3196, 3362, 3532, 3706
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_blocks_L[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12,
|
|
|
|
12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_blocks_M[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
1, 1, 1, 2, 2, 4, 4, 4, 5, 5, 5, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20,
|
|
|
|
21, 23, 25, 26, 28, 29, 31, 33, 35, 37, 38, 40, 43, 45, 47, 49
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_blocks_Q[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
1, 1, 2, 2, 4, 4, 6, 6, 8, 8, 8, 10, 12, 16, 12, 17, 16, 18, 21, 20, 23, 23, 25,
|
|
|
|
27, 29, 34, 34, 35, 38, 40, 43, 45, 48, 51, 53, 56, 59, 62, 65, 68
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_blocks_H[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30,
|
|
|
|
32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_sizes[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
21, 25, 29, 33, 37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, 89, 93, 97,
|
|
|
|
101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 169, 173, 177
|
2009-10-07 08:03:00 +13:00
|
|
|
};
|
2009-10-12 08:52:13 +13:00
|
|
|
|
2009-11-01 02:18:27 +13:00
|
|
|
static int micro_qr_sizes[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
11, 13, 15, 17
|
2009-11-01 02:18:27 +13:00
|
|
|
};
|
|
|
|
|
2009-10-12 08:52:13 +13:00
|
|
|
static int qr_align_loopsize[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
0, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7
|
2009-10-12 08:52:13 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static int qr_table_e1[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
6, 18, 0, 0, 0, 0, 0,
|
|
|
|
6, 22, 0, 0, 0, 0, 0,
|
|
|
|
6, 26, 0, 0, 0, 0, 0,
|
|
|
|
6, 30, 0, 0, 0, 0, 0,
|
|
|
|
6, 34, 0, 0, 0, 0, 0,
|
|
|
|
6, 22, 38, 0, 0, 0, 0,
|
|
|
|
6, 24, 42, 0, 0, 0, 0,
|
|
|
|
6, 26, 46, 0, 0, 0, 0,
|
|
|
|
6, 28, 50, 0, 0, 0, 0,
|
|
|
|
6, 30, 54, 0, 0, 0, 0,
|
|
|
|
6, 32, 58, 0, 0, 0, 0,
|
|
|
|
6, 34, 62, 0, 0, 0, 0,
|
|
|
|
6, 26, 46, 66, 0, 0, 0,
|
|
|
|
6, 26, 48, 70, 0, 0, 0,
|
|
|
|
6, 26, 50, 74, 0, 0, 0,
|
|
|
|
6, 30, 54, 78, 0, 0, 0,
|
|
|
|
6, 30, 56, 82, 0, 0, 0,
|
|
|
|
6, 30, 58, 86, 0, 0, 0,
|
|
|
|
6, 34, 62, 90, 0, 0, 0,
|
|
|
|
6, 28, 50, 72, 94, 0, 0,
|
|
|
|
6, 26, 50, 74, 98, 0, 0,
|
|
|
|
6, 30, 54, 78, 102, 0, 0,
|
|
|
|
6, 28, 54, 80, 106, 0, 0,
|
|
|
|
6, 32, 58, 84, 110, 0, 0,
|
|
|
|
6, 30, 58, 86, 114, 0, 0,
|
|
|
|
6, 34, 62, 90, 118, 0, 0,
|
|
|
|
6, 26, 50, 74, 98, 122, 0,
|
|
|
|
6, 30, 54, 78, 102, 126, 0,
|
|
|
|
6, 26, 52, 78, 104, 130, 0,
|
|
|
|
6, 30, 56, 82, 108, 134, 0,
|
|
|
|
6, 34, 60, 86, 112, 138, 0,
|
|
|
|
6, 30, 58, 86, 114, 142, 0,
|
|
|
|
6, 34, 62, 90, 118, 146, 0,
|
|
|
|
6, 30, 54, 78, 102, 126, 150,
|
|
|
|
6, 24, 50, 76, 102, 128, 154,
|
|
|
|
6, 28, 54, 80, 106, 132, 158,
|
|
|
|
6, 32, 58, 84, 110, 136, 162,
|
|
|
|
6, 26, 54, 82, 110, 138, 166,
|
|
|
|
6, 30, 58, 86, 114, 142, 170
|
2009-10-12 08:52:13 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static unsigned int qr_annex_c[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
/* Format information bit sequences */
|
|
|
|
0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, 0x77c4, 0x72f3, 0x7daa, 0x789d,
|
|
|
|
0x662f, 0x6318, 0x6c41, 0x6976, 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b,
|
|
|
|
0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed
|
2009-10-12 08:52:13 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
static long int qr_annex_d[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
/* Version information bit sequences */
|
|
|
|
0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, 0x0f928, 0x10b78,
|
|
|
|
0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, 0x177ec, 0x18ec4, 0x191e1, 0x1afab,
|
|
|
|
0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b,
|
|
|
|
0x2542e, 0x26a64, 0x27541, 0x28c69
|
2009-10-12 08:52:13 +13:00
|
|
|
};
|
|
|
|
|
2009-11-01 02:18:27 +13:00
|
|
|
static int qr_annex_c1[] = {
|
2016-02-21 00:29:19 +13:00
|
|
|
/* Micro QR Code format information */
|
|
|
|
0x4445, 0x4172, 0x4e2b, 0x4b1c, 0x55ae, 0x5099, 0x5fc0, 0x5af7, 0x6793, 0x62a4, 0x6dfd, 0x68ca, 0x7678, 0x734f,
|
|
|
|
0x7c16, 0x7921, 0x06de, 0x03e9, 0x0cb0, 0x0987, 0x1735, 0x1202, 0x1d5b, 0x186c, 0x2508, 0x203f, 0x2f66, 0x2a51, 0x34e3,
|
|
|
|
0x31d4, 0x3e8d, 0x3bba
|
2009-11-01 02:18:27 +13:00
|
|
|
};
|