1 /* 2 * qrencode - QR Code encoder 3 * 4 * Micro QR Code specification in convenient format. 5 * Copyright (C) 2006-2011 Kentaro Fukuchi <kentaro@fukuchi.org> 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef __MQRSPEC_H__ 23 #define __MQRSPEC_H__ 24 25 #include "qrencode.h" 26 27 /****************************************************************************** 28 * Version and capacity 29 *****************************************************************************/ 30 31 /** 32 * Maximum width of a symbol 33 */ 34 #define MQRSPEC_WIDTH_MAX 17 35 36 /** 37 * Return maximum data code length (bits) for the version. 38 * @param version 39 * @param level 40 * @return maximum size (bits) 41 */ 42 extern int MQRspec_getDataLengthBit(int version, QRecLevel level); 43 44 /** 45 * Return maximum data code length (bytes) for the version. 46 * @param version 47 * @param level 48 * @return maximum size (bytes) 49 */ 50 extern int MQRspec_getDataLength(int version, QRecLevel level); 51 52 /** 53 * Return maximum error correction code length (bytes) for the version. 54 * @param version 55 * @param level 56 * @return ECC size (bytes) 57 */ 58 extern int MQRspec_getECCLength(int version, QRecLevel level); 59 60 /** 61 * Return a version number that satisfies the input code length. 62 * @param size input code length (byte) 63 * @param level 64 * @return version number 65 */ 66 extern int MQRspec_getMinimumVersion(int size, QRecLevel level); 67 68 /** 69 * Return the width of the symbol for the version. 70 * @param version 71 * @return width 72 */ 73 extern int MQRspec_getWidth(int version); 74 75 /** 76 * Return the numer of remainder bits. 77 * @param version 78 * @return number of remainder bits 79 */ 80 extern int MQRspec_getRemainder(int version); 81 82 /****************************************************************************** 83 * Length indicator 84 *****************************************************************************/ 85 86 /** 87 * Return the size of lenght indicator for the mode and version. 88 * @param mode 89 * @param version 90 * @return the size of the appropriate length indicator (bits). 91 */ 92 extern int MQRspec_lengthIndicator(QRencodeMode mode, int version); 93 94 /** 95 * Return the maximum length for the mode and version. 96 * @param mode 97 * @param version 98 * @return the maximum length (bytes) 99 */ 100 extern int MQRspec_maximumWords(QRencodeMode mode, int version); 101 102 /****************************************************************************** 103 * Version information pattern 104 *****************************************************************************/ 105 106 /** 107 * Return BCH encoded version information pattern that is used for the symbol 108 * of version 7 or greater. Use lower 18 bits. 109 * @param version 110 * @return BCH encoded version information pattern 111 */ 112 extern unsigned int MQRspec_getVersionPattern(int version); 113 114 /****************************************************************************** 115 * Format information 116 *****************************************************************************/ 117 118 /** 119 * Return BCH encoded format information pattern. 120 * @param mask 121 * @param version 122 * @param level 123 * @return BCH encoded format information pattern 124 */ 125 extern unsigned int MQRspec_getFormatInfo(int mask, int version, QRecLevel level); 126 127 /****************************************************************************** 128 * Frame 129 *****************************************************************************/ 130 131 /** 132 * Return a copy of initialized frame. 133 * When the same version is requested twice or more, a copy of cached frame 134 * is returned. 135 * @param version 136 * @return Array of unsigned char. You can free it by free(). 137 */ 138 extern unsigned char *MQRspec_newFrame(int version); 139 140 /** 141 * Clear the frame cache. Typically for debug. 142 */ 143 extern void MQRspec_clearCache(void); 144 145 /****************************************************************************** 146 * Mode indicator 147 *****************************************************************************/ 148 149 /** 150 * Mode indicator. See Table 2 in Appendix 1 of JIS X0510:2004, pp.107. 151 */ 152 #define MQRSPEC_MODEID_NUM 0 153 #define MQRSPEC_MODEID_AN 1 154 #define MQRSPEC_MODEID_8 2 155 #define MQRSPEC_MODEID_KANJI 3 156 157 #endif /* __MQRSPEC_H__ */ 158