QtSDKとqrencodeを使ったQRコード画像生成
Revisión | 0a2ecf4b64fa1cbf444e1b68aaa30553815497bd (tree) |
---|---|
Tiempo | 2013-03-09 13:34:22 |
Autor | alucky4416 <alucky4416@user...> |
Commiter | alucky4416 |
CHG: replace qrencode.dll to libqrencode.dll(mingw)
@@ -0,0 +1,51 @@ | ||
1 | + | |
2 | +CPPFLAGS = -Imingw -Icharset -I. | |
3 | +CFLAGS = -Imingw -Icharset -I. | |
4 | + | |
5 | + | |
6 | +DEFS = -DHAVE_CONFIG_H | |
7 | + | |
8 | + | |
9 | +CC = gcc | |
10 | +CXX = g++ | |
11 | +CXXFLAGS = -O2 | |
12 | +CCFLAGS = -O2 | |
13 | +CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS) | |
14 | +CCOMPILE = $(CC) $(DEFS) $(INCLUDES) $(CFLAGS) $(CCFLAGS) | |
15 | +CXXLD = $(CXX) | |
16 | +LDFLAGS = -shared -Wl,--out-implib,libqrencode.a | |
17 | +CXXLINK = $(CXXLD) $(CXXFLAGS) $(LDFLAGS) -o $@ | |
18 | + | |
19 | +CONFIG_HEADER = config.h | |
20 | +LIBRARIES = $(lib_LIBRARIES) | |
21 | + | |
22 | +libqrencode_a_OBJECTS = qrencode.o \ | |
23 | + qrinput.o \ | |
24 | + bitstream.o \ | |
25 | + qrspec.o \ | |
26 | + rscode.o \ | |
27 | + split.o \ | |
28 | + mask.o \ | |
29 | + mmask.o \ | |
30 | + mqrspec.o | |
31 | + | |
32 | +LIBS = -lmingwex -lmingw32 -lgcc -lmoldname -lmsvcrt -luser32 -lkernel32 | |
33 | + | |
34 | +all: libqrencode.dll | |
35 | + | |
36 | +libqrencode.dll:$(libqrencode_a_OBJECTS) | |
37 | + if exist $@ del $@ | |
38 | + $(CXXLINK) $(LDFLAGS) $(libqrencode_a_OBJECTS) $(libqrencode_LDADD) $(LIBS) | |
39 | + | |
40 | +libqrencode_s.a: $(libqrencode_a_OBJECTS) | |
41 | + if exist $@ del $@ | |
42 | + ar cru $@ $(libqrencode_a_OBJECTS) | |
43 | + ranlib $@ | |
44 | + | |
45 | +.cc.o: | |
46 | + $(CXXCOMPILE) -c $< -o $@ | |
47 | +.cpp.o: | |
48 | + $(CXXCOMPILE) -c $< -o $@ | |
49 | +.c.o: | |
50 | + $(CCOMPILE) -c $< -o $@ | |
51 | + |
@@ -0,0 +1,95 @@ | ||
1 | +/* config.h. Generated from config.h.in by configure. */ | |
2 | +/* config.h.in. Generated from configure.ac by autoheader. */ | |
3 | + | |
4 | +/* Define to 1 if you have the <dlfcn.h> header file. */ | |
5 | +#define HAVE_DLFCN_H 0 | |
6 | + | |
7 | +/* Define if you have the iconv() function and it works. */ | |
8 | +/* #undef HAVE_ICONV */ | |
9 | + | |
10 | +/* Define to 1 if you have the <inttypes.h> header file. */ | |
11 | +#define HAVE_INTTYPES_H 1 | |
12 | + | |
13 | +/* Define to 1 if you have the <memory.h> header file. */ | |
14 | +#define HAVE_MEMORY_H 1 | |
15 | + | |
16 | +/* Define to 1 if you have the <stdint.h> header file. */ | |
17 | +#define HAVE_STDINT_H 1 | |
18 | + | |
19 | +/* Define to 1 if you have the <stdlib.h> header file. */ | |
20 | +#define HAVE_STDLIB_H 1 | |
21 | + | |
22 | +/* Define to 1 if you have the `strdup' function. */ | |
23 | +#define HAVE_STRDUP 1 | |
24 | + | |
25 | +/* Define to 1 if you have the <strings.h> header file. */ | |
26 | +#define HAVE_STRINGS_H 1 | |
27 | + | |
28 | +/* Define to 1 if you have the <string.h> header file. */ | |
29 | +#define HAVE_STRING_H 1 | |
30 | + | |
31 | +/* Define to 1 if you have the <sys/stat.h> header file. */ | |
32 | +#define HAVE_SYS_STAT_H 1 | |
33 | + | |
34 | +/* Define to 1 if you have the <sys/types.h> header file. */ | |
35 | +#define HAVE_SYS_TYPES_H 1 | |
36 | + | |
37 | +/* Define to 1 if you have the <unistd.h> header file. */ | |
38 | +#define HAVE_UNISTD_H 1 | |
39 | + | |
40 | +/* Define to the sub-directory in which libtool stores uninstalled libraries. | |
41 | + */ | |
42 | +#define LT_OBJDIR ".libs/" | |
43 | + | |
44 | +/* Major version number */ | |
45 | +#define MAJOR_VERSION 3 | |
46 | + | |
47 | +/* Micro version number */ | |
48 | +#define MICRO_VERSION 1 | |
49 | + | |
50 | +/* Minor version number */ | |
51 | +#define MINOR_VERSION 4 | |
52 | + | |
53 | +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ | |
54 | +/* #undef NO_MINUS_C_MINUS_O */ | |
55 | + | |
56 | +/* Name of package */ | |
57 | +#define PACKAGE "qrencode" | |
58 | + | |
59 | +/* Define to the address where bug reports for this package should be sent. */ | |
60 | +#define PACKAGE_BUGREPORT "" | |
61 | + | |
62 | +/* Define to the full name of this package. */ | |
63 | +#define PACKAGE_NAME "" | |
64 | + | |
65 | +/* Define to the full name and version of this package. */ | |
66 | +#define PACKAGE_STRING "" | |
67 | + | |
68 | +/* Define to the one symbol short name of this package. */ | |
69 | +#define PACKAGE_TARNAME "" | |
70 | + | |
71 | +/* Define to the home page for this package. */ | |
72 | +#define PACKAGE_URL "" | |
73 | + | |
74 | +/* Define to the version of this package. */ | |
75 | +#define PACKAGE_VERSION "" | |
76 | + | |
77 | +/* Define to 1 if you have the ANSI C header files. */ | |
78 | +#define STDC_HEADERS 1 | |
79 | + | |
80 | +/* Version number of package */ | |
81 | +#define VERSION "3.4.1" | |
82 | + | |
83 | +/* Define to empty if `const' does not conform to ANSI C. */ | |
84 | +/* #undef const */ | |
85 | + | |
86 | +/* Define to `__inline__' or `__inline' if that's what the C compiler | |
87 | + calls it, or to nothing if 'inline' is not supported under any name. */ | |
88 | +#ifndef __cplusplus | |
89 | +/* #undef inline */ | |
90 | +#endif | |
91 | + | |
92 | +/* Define to 'static' if no test programs will be compiled. */ | |
93 | +#define __STATIC static | |
94 | +/* #undef WITH_TESTS */ | |
95 | + |
@@ -0,0 +1,564 @@ | ||
1 | +/** | |
2 | + * qrencode - QR Code encoder | |
3 | + * | |
4 | + * Copyright (C) 2006-2012 Kentaro Fukuchi <kentaro@fukuchi.org> | |
5 | + * | |
6 | + * This library is free software; you can redistribute it and/or | |
7 | + * modify it under the terms of the GNU Lesser General Public | |
8 | + * License as published by the Free Software Foundation; either | |
9 | + * version 2.1 of the License, or any later version. | |
10 | + * | |
11 | + * This library is distributed in the hope that it will be useful, | |
12 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | + * Lesser General Public License for more details. | |
15 | + * | |
16 | + * You should have received a copy of the GNU Lesser General Public | |
17 | + * License along with this library; if not, write to the Free Software | |
18 | + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | + */ | |
20 | + | |
21 | +/** \mainpage | |
22 | + * Libqrencode is a library for encoding data in a QR Code symbol, a kind of 2D | |
23 | + * symbology. | |
24 | + * | |
25 | + * \section encoding Encoding | |
26 | + * | |
27 | + * There are two ways to encode data: <b>encoding a string</b> or | |
28 | + * <b>encoding a structured data</b>. | |
29 | + * | |
30 | + * \subsection encoding-string Encoding a string | |
31 | + * You can encode a string by calling QRcode_encodeString(). | |
32 | + * The given string is parsed automatically and encoded. If you want to encode | |
33 | + * data that can be represented as a C string style (NUL terminated), you can | |
34 | + * simply use this way. | |
35 | + * | |
36 | + * If the input data contains Kanji (Shift-JIS) characters and you want to | |
37 | + * encode them as Kanji in QR Code, you should give QR_MODE_KANJI as a hint. | |
38 | + * Otherwise, all of non-alphanumeric characters are encoded as 8 bit data. | |
39 | + * If you want to encode a whole string in 8 bit mode, use | |
40 | + * QRcode_encodeString8bit() instead. | |
41 | + * | |
42 | + * Please note that a C string can not contain NUL character. If your data | |
43 | + * contains NUL, you should chose the second way. | |
44 | + * | |
45 | + * \subsection encoding-input Encoding a structured data | |
46 | + * You can construct a structured input data manually. If the structure of the | |
47 | + * input data is known, you can use this way. | |
48 | + * At first, create a ::QRinput object by QRinput_new(). Then add input data | |
49 | + * to the QRinput object by QRinput_append(). Finally call QRcode_encodeInput() | |
50 | + * to encode the QRinput data. | |
51 | + * You can reuse the QRinput data again to encode it in other symbols with | |
52 | + * different parameters. | |
53 | + * | |
54 | + * \section result Result | |
55 | + * The encoded symbol is resulted as a ::QRcode object. It will contain | |
56 | + * its version number, width of the symbol and an array represents the symbol. | |
57 | + * See ::QRcode for the details. You can free the object by QRcode_free(). | |
58 | + * | |
59 | + * Please note that the version of the result may be larger than specified. | |
60 | + * In such cases, the input data would be too large to be encoded in a | |
61 | + * symbol of the specified version. | |
62 | + * | |
63 | + * \section structured Structured append | |
64 | + * Libqrencode can generate "Structured-appended" symbols that enables to split | |
65 | + * a large data set into mulitple QR codes. A QR code reader concatenates | |
66 | + * multiple QR code symbols into a string. | |
67 | + * Just like QRcode_encodeString(), you can use QRcode_encodeStringStructured() | |
68 | + * to generate structured-appended symbols. This functions returns an instance | |
69 | + * of ::QRcode_List. The returned list is a singly-linked list of QRcode: you | |
70 | + * can retrieve each QR code in this way: | |
71 | + * | |
72 | + * \code | |
73 | + * QRcode_List *qrcodes; | |
74 | + * QRcode_List *entry; | |
75 | + * QRcode *qrcode; | |
76 | + * | |
77 | + * qrcodes = QRcode_encodeStringStructured(...); | |
78 | + * entry = qrcodes; | |
79 | + * while(entry != NULL) { | |
80 | + * qrcode = entry->code; | |
81 | + * // do something | |
82 | + * entry = entry->next; | |
83 | + * } | |
84 | + * QRcode_List_free(entry); | |
85 | + * \endcode | |
86 | + * | |
87 | + * Instead of using auto-parsing functions, you can construct your own | |
88 | + * structured input. At first, instantiate an object of ::QRinput_Struct | |
89 | + * by calling QRinput_Struct_new(). This object can hold multiple ::QRinput, | |
90 | + * and one QR code is generated for a ::QRinput. | |
91 | + * QRinput_Struct_appendInput() appends a ::QRinput to a ::QRinput_Struct | |
92 | + * object. In order to generate structured-appended symbols, it is required to | |
93 | + * embed headers to each symbol. You can use | |
94 | + * QRinput_Struct_insertStructuredAppendHeaders() to insert appropriate | |
95 | + * headers to each symbol. You should call this function just once before | |
96 | + * encoding symbols. | |
97 | + */ | |
98 | + | |
99 | +#ifndef __QRENCODE_H__ | |
100 | +#define __QRENCODE_H__ | |
101 | + | |
102 | +#if defined(__cplusplus) | |
103 | +extern "C" { | |
104 | +#endif | |
105 | + | |
106 | +/** | |
107 | + * Encoding mode. | |
108 | + */ | |
109 | +typedef enum { | |
110 | + QR_MODE_NUL = -1, ///< Terminator (NUL character). Internal use only | |
111 | + QR_MODE_NUM = 0, ///< Numeric mode | |
112 | + QR_MODE_AN, ///< Alphabet-numeric mode | |
113 | + QR_MODE_8, ///< 8-bit data mode | |
114 | + QR_MODE_KANJI, ///< Kanji (shift-jis) mode | |
115 | + QR_MODE_STRUCTURE, ///< Internal use only | |
116 | + QR_MODE_ECI, ///< ECI mode | |
117 | + QR_MODE_FNC1FIRST, ///< FNC1, first position | |
118 | + QR_MODE_FNC1SECOND, ///< FNC1, second position | |
119 | +} QRencodeMode; | |
120 | + | |
121 | +/** | |
122 | + * Level of error correction. | |
123 | + */ | |
124 | +typedef enum { | |
125 | + QR_ECLEVEL_L = 0, ///< lowest | |
126 | + QR_ECLEVEL_M, | |
127 | + QR_ECLEVEL_Q, | |
128 | + QR_ECLEVEL_H ///< highest | |
129 | +} QRecLevel; | |
130 | + | |
131 | +/** | |
132 | + * Maximum version (size) of QR-code symbol. | |
133 | + */ | |
134 | +#define QRSPEC_VERSION_MAX 40 | |
135 | + | |
136 | +/** | |
137 | + * Maximum version (size) of QR-code symbol. | |
138 | + */ | |
139 | +#define MQRSPEC_VERSION_MAX 4 | |
140 | + | |
141 | + | |
142 | +/****************************************************************************** | |
143 | + * Input data (qrinput.c) | |
144 | + *****************************************************************************/ | |
145 | + | |
146 | +/** | |
147 | + * Singly linked list to contain input strings. An instance of this class | |
148 | + * contains its version and error correction level too. It is required to | |
149 | + * set them by QRinput_setVersion() and QRinput_setErrorCorrectionLevel(), | |
150 | + * or use QRinput_new2() to instantiate an object. | |
151 | + */ | |
152 | +typedef struct _QRinput QRinput; | |
153 | + | |
154 | +/** | |
155 | + * Instantiate an input data object. The version is set to 0 (auto-select) | |
156 | + * and the error correction level is set to QR_ECLEVEL_L. | |
157 | + * @return an input object (initialized). On error, NULL is returned and errno | |
158 | + * is set to indicate the error. | |
159 | + * @throw ENOMEM unable to allocate memory. | |
160 | + */ | |
161 | +extern QRinput *QRinput_new(void); | |
162 | + | |
163 | +/** | |
164 | + * Instantiate an input data object. | |
165 | + * @param version version number. | |
166 | + * @param level Error correction level. | |
167 | + * @return an input object (initialized). On error, NULL is returned and errno | |
168 | + * is set to indicate the error. | |
169 | + * @throw ENOMEM unable to allocate memory for input objects. | |
170 | + * @throw EINVAL invalid arguments. | |
171 | + */ | |
172 | +extern QRinput *QRinput_new2(int version, QRecLevel level); | |
173 | + | |
174 | +/** | |
175 | + * Instantiate an input data object. Object's Micro QR Code flag is set. | |
176 | + * Unlike with full-sized QR Code, version number must be specified (>0). | |
177 | + * @param version version number (1--4). | |
178 | + * @param level Error correction level. | |
179 | + * @return an input object (initialized). On error, NULL is returned and errno | |
180 | + * is set to indicate the error. | |
181 | + * @throw ENOMEM unable to allocate memory for input objects. | |
182 | + * @throw EINVAL invalid arguments. | |
183 | + */ | |
184 | +extern QRinput *QRinput_newMQR(int version, QRecLevel level); | |
185 | + | |
186 | +/** | |
187 | + * Append data to an input object. | |
188 | + * The data is copied and appended to the input object. | |
189 | + * @param input input object. | |
190 | + * @param mode encoding mode. | |
191 | + * @param size size of data (byte). | |
192 | + * @param data a pointer to the memory area of the input data. | |
193 | + * @retval 0 success. | |
194 | + * @retval -1 an error occurred and errno is set to indeicate the error. | |
195 | + * See Execptions for the details. | |
196 | + * @throw ENOMEM unable to allocate memory. | |
197 | + * @throw EINVAL input data is invalid. | |
198 | + * | |
199 | + */ | |
200 | +extern int QRinput_append(QRinput *input, QRencodeMode mode, int size, const unsigned char *data); | |
201 | + | |
202 | +/** | |
203 | + * Append ECI header. | |
204 | + * @param input input object. | |
205 | + * @param ecinum ECI indicator number (0 - 999999) | |
206 | + * @retval 0 success. | |
207 | + * @retval -1 an error occurred and errno is set to indeicate the error. | |
208 | + * See Execptions for the details. | |
209 | + * @throw ENOMEM unable to allocate memory. | |
210 | + * @throw EINVAL input data is invalid. | |
211 | + * | |
212 | + */ | |
213 | +extern int QRinput_appendECIheader(QRinput *input, unsigned int ecinum); | |
214 | + | |
215 | +/** | |
216 | + * Get current version. | |
217 | + * @param input input object. | |
218 | + * @return current version. | |
219 | + */ | |
220 | +extern int QRinput_getVersion(QRinput *input); | |
221 | + | |
222 | +/** | |
223 | + * Set version of the QR code that is to be encoded. | |
224 | + * This function cannot be applied to Micro QR Code. | |
225 | + * @param input input object. | |
226 | + * @param version version number (0 = auto) | |
227 | + * @retval 0 success. | |
228 | + * @retval -1 invalid argument. | |
229 | + */ | |
230 | +extern int QRinput_setVersion(QRinput *input, int version); | |
231 | + | |
232 | +/** | |
233 | + * Get current error correction level. | |
234 | + * @param input input object. | |
235 | + * @return Current error correcntion level. | |
236 | + */ | |
237 | +extern QRecLevel QRinput_getErrorCorrectionLevel(QRinput *input); | |
238 | + | |
239 | +/** | |
240 | + * Set error correction level of the QR code that is to be encoded. | |
241 | + * This function cannot be applied to Micro QR Code. | |
242 | + * @param input input object. | |
243 | + * @param level Error correction level. | |
244 | + * @retval 0 success. | |
245 | + * @retval -1 invalid argument. | |
246 | + */ | |
247 | +extern int QRinput_setErrorCorrectionLevel(QRinput *input, QRecLevel level); | |
248 | + | |
249 | +/** | |
250 | + * Set version and error correction level of the QR code at once. | |
251 | + * This function is recommened for Micro QR Code. | |
252 | + * @param input input object. | |
253 | + * @param version version number (0 = auto) | |
254 | + * @param level Error correction level. | |
255 | + * @retval 0 success. | |
256 | + * @retval -1 invalid argument. | |
257 | + */ | |
258 | +extern int QRinput_setVersionAndErrorCorrectionLevel(QRinput *input, int version, QRecLevel level); | |
259 | + | |
260 | +/** | |
261 | + * Free the input object. | |
262 | + * All of data chunks in the input object are freed too. | |
263 | + * @param input input object. | |
264 | + */ | |
265 | +extern void QRinput_free(QRinput *input); | |
266 | + | |
267 | +/** | |
268 | + * Validate the input data. | |
269 | + * @param mode encoding mode. | |
270 | + * @param size size of data (byte). | |
271 | + * @param data a pointer to the memory area of the input data. | |
272 | + * @retval 0 success. | |
273 | + * @retval -1 invalid arguments. | |
274 | + */ | |
275 | +extern int QRinput_check(QRencodeMode mode, int size, const unsigned char *data); | |
276 | + | |
277 | +/** | |
278 | + * Set of QRinput for structured symbols. | |
279 | + */ | |
280 | +typedef struct _QRinput_Struct QRinput_Struct; | |
281 | + | |
282 | +/** | |
283 | + * Instantiate a set of input data object. | |
284 | + * @return an instance of QRinput_Struct. On error, NULL is returned and errno | |
285 | + * is set to indicate the error. | |
286 | + * @throw ENOMEM unable to allocate memory. | |
287 | + */ | |
288 | +extern QRinput_Struct *QRinput_Struct_new(void); | |
289 | + | |
290 | +/** | |
291 | + * Set parity of structured symbols. | |
292 | + * @param s structured input object. | |
293 | + * @param parity parity of s. | |
294 | + */ | |
295 | +extern void QRinput_Struct_setParity(QRinput_Struct *s, unsigned char parity); | |
296 | + | |
297 | +/** | |
298 | + * Append a QRinput object to the set. QRinput created by QRinput_newMQR() | |
299 | + * will be rejected. | |
300 | + * @warning never append the same QRinput object twice or more. | |
301 | + * @param s structured input object. | |
302 | + * @param input an input object. | |
303 | + * @retval >0 number of input objects in the structure. | |
304 | + * @retval -1 an error occurred. See Exceptions for the details. | |
305 | + * @throw ENOMEM unable to allocate memory. | |
306 | + * @throw EINVAL invalid arguments. | |
307 | + */ | |
308 | +extern int QRinput_Struct_appendInput(QRinput_Struct *s, QRinput *input); | |
309 | + | |
310 | +/** | |
311 | + * Free all of QRinput in the set. | |
312 | + * @param s a structured input object. | |
313 | + */ | |
314 | +extern void QRinput_Struct_free(QRinput_Struct *s); | |
315 | + | |
316 | +/** | |
317 | + * Split a QRinput to QRinput_Struct. It calculates a parity, set it, then | |
318 | + * insert structured-append headers. QRinput created by QRinput_newMQR() will | |
319 | + * be rejected. | |
320 | + * @param input input object. Version number and error correction level must be | |
321 | + * set. | |
322 | + * @return a set of input data. On error, NULL is returned, and errno is set | |
323 | + * to indicate the error. See Exceptions for the details. | |
324 | + * @throw ERANGE input data is too large. | |
325 | + * @throw EINVAL invalid input data. | |
326 | + * @throw ENOMEM unable to allocate memory. | |
327 | + */ | |
328 | +extern QRinput_Struct *QRinput_splitQRinputToStruct(QRinput *input); | |
329 | + | |
330 | +/** | |
331 | + * Insert structured-append headers to the input structure. It calculates | |
332 | + * a parity and set it if the parity is not set yet. | |
333 | + * @param s input structure | |
334 | + * @retval 0 success. | |
335 | + * @retval -1 an error occurred and errno is set to indeicate the error. | |
336 | + * See Execptions for the details. | |
337 | + * @throw EINVAL invalid input object. | |
338 | + * @throw ENOMEM unable to allocate memory. | |
339 | + */ | |
340 | +extern int QRinput_Struct_insertStructuredAppendHeaders(QRinput_Struct *s); | |
341 | + | |
342 | +/** | |
343 | + * Set FNC1-1st position flag. | |
344 | + */ | |
345 | +extern int QRinput_setFNC1First(QRinput *input); | |
346 | + | |
347 | +/** | |
348 | + * Set FNC1-2nd position flag and application identifier. | |
349 | + */ | |
350 | +extern int QRinput_setFNC1Second(QRinput *input, unsigned char appid); | |
351 | + | |
352 | +/****************************************************************************** | |
353 | + * QRcode output (qrencode.c) | |
354 | + *****************************************************************************/ | |
355 | + | |
356 | +/** | |
357 | + * QRcode class. | |
358 | + * Symbol data is represented as an array contains width*width uchars. | |
359 | + * Each uchar represents a module (dot). If the less significant bit of | |
360 | + * the uchar is 1, the corresponding module is black. The other bits are | |
361 | + * meaningless for usual applications, but here its specification is described. | |
362 | + * | |
363 | + * <pre> | |
364 | + * MSB 76543210 LSB | |
365 | + * |||||||`- 1=black/0=white | |
366 | + * ||||||`-- data and ecc code area | |
367 | + * |||||`--- format information | |
368 | + * ||||`---- version information | |
369 | + * |||`----- timing pattern | |
370 | + * ||`------ alignment pattern | |
371 | + * |`------- finder pattern and separator | |
372 | + * `-------- non-data modules (format, timing, etc.) | |
373 | + * </pre> | |
374 | + */ | |
375 | +typedef struct { | |
376 | + int version; ///< version of the symbol | |
377 | + int width; ///< width of the symbol | |
378 | + unsigned char *data; ///< symbol data | |
379 | +} QRcode; | |
380 | + | |
381 | +/** | |
382 | + * Singly-linked list of QRcode. Used to represent a structured symbols. | |
383 | + * A list is terminated with NULL. | |
384 | + */ | |
385 | +typedef struct _QRcode_List { | |
386 | + QRcode *code; | |
387 | + struct _QRcode_List *next; | |
388 | +} QRcode_List; | |
389 | + | |
390 | +/** | |
391 | + * Create a symbol from the input data. | |
392 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
393 | + * @param input input data. | |
394 | + * @return an instance of QRcode class. The version of the result QRcode may | |
395 | + * be larger than the designated version. On error, NULL is returned, | |
396 | + * and errno is set to indicate the error. See Exceptions for the | |
397 | + * details. | |
398 | + * @throw EINVAL invalid input object. | |
399 | + * @throw ENOMEM unable to allocate memory for input objects. | |
400 | + */ | |
401 | +extern QRcode *QRcode_encodeInput(QRinput *input); | |
402 | + | |
403 | +/** | |
404 | + * Create a symbol from the string. The library automatically parses the input | |
405 | + * string and encodes in a QR Code symbol. | |
406 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
407 | + * @param string input string. It must be NUL terminated. | |
408 | + * @param version version of the symbol. If 0, the library chooses the minimum | |
409 | + * version for the given input data. | |
410 | + * @param level error correction level. | |
411 | + * @param hint tell the library how non-alphanumerical characters should be | |
412 | + * encoded. If QR_MODE_KANJI is given, kanji characters will be | |
413 | + * encoded as Shif-JIS characters. If QR_MODE_8 is given, all of | |
414 | + * non-alphanumerical characters will be encoded as is. If you want | |
415 | + * to embed UTF-8 string, choose this. | |
416 | + * @param casesensitive case-sensitive(1) or not(0). | |
417 | + * @return an instance of QRcode class. The version of the result QRcode may | |
418 | + * be larger than the designated version. On error, NULL is returned, | |
419 | + * and errno is set to indicate the error. See Exceptions for the | |
420 | + * details. | |
421 | + * @throw EINVAL invalid input object. | |
422 | + * @throw ENOMEM unable to allocate memory for input objects. | |
423 | + * @throw ERANGE input data is too large. | |
424 | + */ | |
425 | +extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); | |
426 | + | |
427 | +/** | |
428 | + * Same to QRcode_encodeString(), but encode whole data in 8-bit mode. | |
429 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
430 | + */ | |
431 | +extern QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level); | |
432 | + | |
433 | +/** | |
434 | + * Micro QR Code version of QRcode_encodeString(). | |
435 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
436 | + */ | |
437 | +extern QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); | |
438 | + | |
439 | +/** | |
440 | + * Micro QR Code version of QRcode_encodeString8bit(). | |
441 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
442 | + */ | |
443 | +extern QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level); | |
444 | + | |
445 | +/** | |
446 | + * Encode byte stream (may include '\0') in 8-bit mode. | |
447 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
448 | + * @param size size of the input data. | |
449 | + * @param data input data. | |
450 | + * @param version version of the symbol. If 0, the library chooses the minimum | |
451 | + * version for the given input data. | |
452 | + * @param level error correction level. | |
453 | + * @throw EINVAL invalid input object. | |
454 | + * @throw ENOMEM unable to allocate memory for input objects. | |
455 | + * @throw ERANGE input data is too large. | |
456 | + */ | |
457 | +extern QRcode *QRcode_encodeData(int size, const unsigned char *data, int version, QRecLevel level); | |
458 | + | |
459 | +/** | |
460 | + * Micro QR Code version of QRcode_encodeData(). | |
461 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
462 | + */ | |
463 | +extern QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level); | |
464 | + | |
465 | +/** | |
466 | + * Free the instance of QRcode class. | |
467 | + * @param qrcode an instance of QRcode class. | |
468 | + */ | |
469 | +extern void QRcode_free(QRcode *qrcode); | |
470 | + | |
471 | +/** | |
472 | + * Create structured symbols from the input data. | |
473 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
474 | + * @param s | |
475 | + * @return a singly-linked list of QRcode. | |
476 | + */ | |
477 | +extern QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s); | |
478 | + | |
479 | +/** | |
480 | + * Create structured symbols from the string. The library automatically parses | |
481 | + * the input string and encodes in a QR Code symbol. | |
482 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
483 | + * @param string input string. It must be NUL terminated. | |
484 | + * @param version version of the symbol. | |
485 | + * @param level error correction level. | |
486 | + * @param hint tell the library how non-alphanumerical characters should be | |
487 | + * encoded. If QR_MODE_KANJI is given, kanji characters will be | |
488 | + * encoded as Shif-JIS characters. If QR_MODE_8 is given, all of | |
489 | + * non-alphanumerical characters will be encoded as is. If you want | |
490 | + * to embed UTF-8 string, choose this. | |
491 | + * @param casesensitive case-sensitive(1) or not(0). | |
492 | + * @return a singly-linked list of QRcode. On error, NULL is returned, and | |
493 | + * errno is set to indicate the error. See Exceptions for the details. | |
494 | + * @throw EINVAL invalid input object. | |
495 | + * @throw ENOMEM unable to allocate memory for input objects. | |
496 | + */ | |
497 | +extern QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); | |
498 | + | |
499 | +/** | |
500 | + * Same to QRcode_encodeStringStructured(), but encode whole data in 8-bit mode. | |
501 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
502 | + */ | |
503 | +extern QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level); | |
504 | + | |
505 | +/** | |
506 | + * Create structured symbols from byte stream (may include '\0'). Wholde data | |
507 | + * are encoded in 8-bit mode. | |
508 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
509 | + * @param size size of the input data. | |
510 | + * @param data input dat. | |
511 | + * @param version version of the symbol. | |
512 | + * @param level error correction level. | |
513 | + * @return a singly-linked list of QRcode. On error, NULL is returned, and | |
514 | + * errno is set to indicate the error. See Exceptions for the details. | |
515 | + * @throw EINVAL invalid input object. | |
516 | + * @throw ENOMEM unable to allocate memory for input objects. | |
517 | + */ | |
518 | +extern QRcode_List *QRcode_encodeDataStructured(int size, const unsigned char *data, int version, QRecLevel level); | |
519 | + | |
520 | +/** | |
521 | + * Return the number of symbols included in a QRcode_List. | |
522 | + * @param qrlist a head entry of a QRcode_List. | |
523 | + * @return number of symbols in the list. | |
524 | + */ | |
525 | +extern int QRcode_List_size(QRcode_List *qrlist); | |
526 | + | |
527 | +/** | |
528 | + * Free the QRcode_List. | |
529 | + * @param qrlist a head entry of a QRcode_List. | |
530 | + */ | |
531 | +extern void QRcode_List_free(QRcode_List *qrlist); | |
532 | + | |
533 | + | |
534 | +/****************************************************************************** | |
535 | + * System utilities | |
536 | + *****************************************************************************/ | |
537 | + | |
538 | +/** | |
539 | + * Return a string that identifies the library version. | |
540 | + * @param major_version | |
541 | + * @param minor_version | |
542 | + * @param micro_version | |
543 | + */ | |
544 | +extern void QRcode_APIVersion(int *major_version, int *minor_version, int *micro_version); | |
545 | + | |
546 | +/** | |
547 | + * Return a string that identifies the library version. | |
548 | + * @return a string identifies the library version. The string is held by the | |
549 | + * library. Do NOT free it. | |
550 | + */ | |
551 | +extern char *QRcode_APIVersionString(void); | |
552 | + | |
553 | +/** | |
554 | + * Clear all caches. This is only for debug purpose. If you are attacking a | |
555 | + * complicated memory leak bug, try this to reduce the reachable blocks record. | |
556 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
557 | + */ | |
558 | +extern void QRcode_clearCache(void); | |
559 | + | |
560 | +#if defined(__cplusplus) | |
561 | +} | |
562 | +#endif | |
563 | + | |
564 | +#endif /* __QRENCODE_H__ */ |
@@ -1,23 +1,25 @@ | ||
1 | -#------------------------------------------------- | |
2 | -# | |
3 | -# Project created by QtCreator 2012-10-20T16:21:02 | |
4 | -# | |
5 | -#------------------------------------------------- | |
6 | - | |
7 | -QT += core gui | |
8 | - | |
9 | -TARGET = QtQREncode | |
10 | -TEMPLATE = app | |
11 | - | |
12 | - | |
13 | -SOURCES += main.cpp\ | |
14 | - mainwindow.cpp | |
15 | - | |
16 | -HEADERS += mainwindow.h | |
17 | - | |
18 | -FORMS += mainwindow.ui | |
19 | - | |
20 | -win32:INCLUDEPATH += $$PWD/QRcode-dll/ | |
21 | - | |
22 | -win32:LIBS += $$PWD/QRcode-dll/libqrencode.dll.a | |
23 | -unix:LIBS += -lqrencode | |
1 | +#------------------------------------------------- | |
2 | +# | |
3 | +# Project created by QtCreator 2012-10-20T16:21:02 | |
4 | +# | |
5 | +#------------------------------------------------- | |
6 | + | |
7 | +QT += core gui | |
8 | + | |
9 | +TARGET = QtQREncode | |
10 | +TEMPLATE = app | |
11 | + | |
12 | + | |
13 | +SOURCES += main.cpp\ | |
14 | + mainwindow.cpp | |
15 | + | |
16 | +HEADERS += mainwindow.h | |
17 | + | |
18 | +FORMS += mainwindow.ui | |
19 | + | |
20 | +#win32:INCLUDEPATH += $$PWD/QRcode-dll/ | |
21 | +win32:INCLUDEPATH += $$PWD/QRencode-dll-mingw/ | |
22 | + | |
23 | +#win32:LIBS += $$PWD/QRcode-dll/libqrencode.dll.a | |
24 | +win32:LIBS += $$PWD/QRencode-dll-mingw/libqrencode.a | |
25 | +unix:LIBS += -lqrencode |
@@ -1,85 +1,21 @@ | ||
1 | 1 | QtQREncode: qrencodeライブラリ を使ったQRコードの生成 Qt GUI ソフト |
2 | 2 | alucky4416@users.sourceforge.jp |
3 | 3 | |
4 | -Time-stamp: "2013/03/03 18:57:40 +0900" | |
4 | +Time-stamp: "2013/03/09 13:32:46 +0900" | |
5 | 5 | |
6 | 6 | qrencodeライブラリを使ったQRコード生成用のGUIアプリケーションです。 |
7 | -qrencode 3.3.1 と QtSDK1.2.1 を使って開発しています。 | |
8 | -本ソフトのライセンスはGPLとします。 | |
7 | +libqrencode と QtSDK1.2.1 を使って開発しています。 | |
8 | +本ソフト(QtQREncode)のライセンスはGPLとします。 | |
9 | 9 | |
10 | - QRコードの生成にはqrencodeライブラリを使用しています。現在はv3.3.1を使用。 | |
10 | + QRコードの生成にはlibqrencodeライブラリを使用しています。現在はv3.3.1を使用。 | |
11 | 11 | http://fukuchi.org/works/qrencode/index.html.ja |
12 | 12 | |
13 | 13 | Linux用には上記のURLから、ソースを入手してライブラリをインストール |
14 | 14 | してください。 |
15 | - | |
16 | 15 | Windows用にはlibqrencodeをDLL化したものが必要です。 |
17 | -付属のQRcode-dll/qrencode.dllは、こちらでビルドしたものです。 | |
18 | -注意! 利用にあたっては qrencode.dllと同じフォルダにある instrsup.dll も | |
19 | -exe と同じフォルダにコピーしてください。instrsup.dllは今回ビルドした | |
20 | -開発環境用のサポートライブラリで、libqrencode自体が必要としているわけ | |
21 | -ではありません。 | |
22 | - | |
23 | -QRcode-dll以下のファイルはMinGW用のライブラリファイルを作成するための | |
24 | -作業用ファイルです。 | |
25 | - なお、DLL化にあたって、qrencode.c に以下の部分をファイルの末尾に追加しました。 | |
26 | -QRcode_encodeStringToU8Array()関数は私が別の用途で利用するために追加して | |
27 | -いますので、この関数が無くてもDLL作成に支障はありません。 | |
28 | -最低限必要なのはDLLMain()だけです。 | |
29 | - mingw環境でbuiildしなおせば、以下のソース修正も不要と思います。 | |
30 | - | |
31 | - | |
32 | --- ここから ------------------------------------------------------------------------------------------ | |
33 | - | |
34 | -//============================================================================== | |
35 | -// Add Function | |
36 | -__declspec(dllexport) | |
37 | -int QRcode_encodeStringToU8Array(unsigned char *instr, int instr_len, unsigned char qrcode_data[], int *qrcode_width) | |
38 | -{ | |
39 | - int casesensitive = 1; | |
40 | - int version = 0; | |
41 | - QRecLevel level = QR_ECLEVEL_L; | |
42 | - QRencodeMode hint = QR_MODE_8; | |
43 | - QRcode *code; | |
44 | - | |
45 | - if (qrcode_data == NULL || qrcode_width == NULL) return -1; | |
46 | - | |
47 | - code = QRcode_encodeData(instr_len, instr, version, level); | |
48 | - if (code == NULL) return -1; | |
49 | - | |
50 | - *qrcode_width = code->width; | |
51 | - memcpy(qrcode_data, code->data, (code->width * code->width)); // copy QRCode data | |
52 | - | |
53 | - QRcode_free(code); | |
54 | - | |
55 | - return 0; | |
56 | -} | |
57 | - | |
58 | -//============================================================================== | |
59 | -// DLL main entry-point functions | |
60 | - | |
61 | -int __stdcall DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) | |
62 | -{ | |
63 | - switch (fdwReason) { | |
64 | - case DLL_PROCESS_ATTACH: | |
65 | - break; | |
66 | - case DLL_PROCESS_DETACH: | |
67 | - break; | |
68 | - } | |
69 | - | |
70 | - return 1; | |
71 | -} | |
72 | - | |
73 | -int __stdcall DllEntryPoint (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) | |
74 | -{ | |
75 | - /* Included for compatibility with Borland */ | |
76 | - | |
77 | - return DllMain (hinstDLL, fdwReason, lpvReserved); | |
78 | -} | |
79 | --- ここまで ------------------------------------------------------------------------------------------ | |
80 | - | |
81 | -qrencode.dllファイルはPATHの通ったフォルダか、EXEと同じ場所においてください。 | |
16 | +付属のQRencode-dll-mingw/libqrencode.dll は、こちらでmingwでビルドしたものです。 | |
17 | +libqrenoce.3.4.1をビルドしました。 | |
82 | 18 | |
83 | - 動作確認は、PuppyLinux 5.2.8とWindowsXPのQtCreator上で行っています。 | |
84 | -Windows用のQtSDKは、MinGW版をを使用。 | |
19 | + QtQREncodeの動作確認は、PuppyLinux 5.2.8とWindowsXPのQtCreator上で行っています。 | |
20 | +Windows用のQtSDKは、MinGW版をを使用しています。 | |
85 | 21 |