QtSDKとqrencodeを使ったQRコード画像生成
Revision | 99bdd2648af806d58c44f8dd6af5b6e04d20eb6c (tree) |
---|---|
Zeit | 2012-10-24 23:06:01 |
Autor | arakaki <alucky4416@user...> |
Commiter | arakaki |
ADD: add qrencode-dll files for Windows(mingw). supported windows.
@@ -0,0 +1,40 @@ | ||
1 | +LIBRARY qrencode.dll | |
2 | +EXPORTS | |
3 | +QRcode_APIVersion | |
4 | +QRcode_APIVersionString | |
5 | +QRcode_List_free | |
6 | +QRcode_List_size | |
7 | +QRcode_clearCache | |
8 | +QRcode_encodeData | |
9 | +QRcode_encodeDataMQR | |
10 | +QRcode_encodeDataStructured | |
11 | +QRcode_encodeInput | |
12 | +QRcode_encodeInputStructured | |
13 | +QRcode_encodeString | |
14 | +QRcode_encodeString8bit | |
15 | +QRcode_encodeString8bitMQR | |
16 | +QRcode_encodeString8bitStructured | |
17 | +QRcode_encodeStringMQR | |
18 | +QRcode_encodeStringStructured | |
19 | +QRcode_encodeStringToU8Array | |
20 | +QRcode_free | |
21 | +QRinput_Struct_appendInput | |
22 | +QRinput_Struct_free | |
23 | +QRinput_Struct_insertStructuredAppendHeaders | |
24 | +QRinput_Struct_new | |
25 | +QRinput_Struct_setParity | |
26 | +QRinput_append | |
27 | +QRinput_appendECIheader | |
28 | +QRinput_check | |
29 | +QRinput_free | |
30 | +QRinput_getErrorCorrectionLevel | |
31 | +QRinput_getVersion | |
32 | +QRinput_new | |
33 | +QRinput_new2 | |
34 | +QRinput_newMQR | |
35 | +QRinput_setErrorCorrectionLevel | |
36 | +QRinput_setFNC1First | |
37 | +QRinput_setFNC1Second | |
38 | +QRinput_setVersion | |
39 | +QRinput_setVersionAndErrorCorrectionLevel | |
40 | +QRinput_splitQRinputToStruct |
@@ -0,0 +1,59 @@ | ||
1 | +Microsoft (R) COFF Binary File Dumper Version 6.00.8447 | |
2 | +Copyright (C) Microsoft Corp 1992-1998. All rights reserved. | |
3 | + | |
4 | + | |
5 | +Dump of file qrencode.lib | |
6 | + | |
7 | +File Type: LIBRARY | |
8 | + | |
9 | + Exports | |
10 | + | |
11 | + ordinal name | |
12 | + | |
13 | + _QRcode_APIVersion | |
14 | + _QRcode_APIVersionString | |
15 | + _QRcode_List_free | |
16 | + _QRcode_List_size | |
17 | + _QRcode_clearCache | |
18 | + _QRcode_encodeData | |
19 | + _QRcode_encodeDataMQR | |
20 | + _QRcode_encodeDataStructured | |
21 | + _QRcode_encodeInput | |
22 | + _QRcode_encodeInputStructured | |
23 | + _QRcode_encodeString | |
24 | + _QRcode_encodeString8bit | |
25 | + _QRcode_encodeString8bitMQR | |
26 | + _QRcode_encodeString8bitStructured | |
27 | + _QRcode_encodeStringMQR | |
28 | + _QRcode_encodeStringStructured | |
29 | + _QRcode_encodeStringToU8Array | |
30 | + _QRcode_free | |
31 | + _QRinput_Struct_appendInput | |
32 | + _QRinput_Struct_free | |
33 | + _QRinput_Struct_insertStructuredAppendHeaders | |
34 | + _QRinput_Struct_new | |
35 | + _QRinput_Struct_setParity | |
36 | + _QRinput_append | |
37 | + _QRinput_appendECIheader | |
38 | + _QRinput_check | |
39 | + _QRinput_free | |
40 | + _QRinput_getErrorCorrectionLevel | |
41 | + _QRinput_getVersion | |
42 | + _QRinput_new | |
43 | + _QRinput_new2 | |
44 | + _QRinput_newMQR | |
45 | + _QRinput_setErrorCorrectionLevel | |
46 | + _QRinput_setFNC1First | |
47 | + _QRinput_setFNC1Second | |
48 | + _QRinput_setVersion | |
49 | + _QRinput_setVersionAndErrorCorrectionLevel | |
50 | + _QRinput_splitQRinputToStruct | |
51 | + | |
52 | + Summary | |
53 | + | |
54 | + 14 .idata$2 | |
55 | + 14 .idata$3 | |
56 | + 9C .idata$4 | |
57 | + 9C .idata$5 | |
58 | + 3CF .idata$6 | |
59 | + E4 .text |
@@ -0,0 +1,565 @@ | ||
1 | +/** | |
2 | + * qrencode - QR Code encoder | |
3 | + * | |
4 | + * Copyright (C) 2006-2011 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 QRcode_List; | |
386 | + | |
387 | +struct _QRcode_List { | |
388 | + QRcode *code; | |
389 | + QRcode_List *next; | |
390 | +}; | |
391 | + | |
392 | +/** | |
393 | + * Create a symbol from the input data. | |
394 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
395 | + * @param input input data. | |
396 | + * @return an instance of QRcode class. The version of the result QRcode may | |
397 | + * be larger than the designated version. On error, NULL is returned, | |
398 | + * and errno is set to indicate the error. See Exceptions for the | |
399 | + * details. | |
400 | + * @throw EINVAL invalid input object. | |
401 | + * @throw ENOMEM unable to allocate memory for input objects. | |
402 | + */ | |
403 | +extern QRcode *QRcode_encodeInput(QRinput *input); | |
404 | + | |
405 | +/** | |
406 | + * Create a symbol from the string. The library automatically parses the input | |
407 | + * string and encodes in a QR Code symbol. | |
408 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
409 | + * @param string input string. It must be NUL terminated. | |
410 | + * @param version version of the symbol. If 0, the library chooses the minimum | |
411 | + * version for the given input data. | |
412 | + * @param level error correction level. | |
413 | + * @param hint tell the library how non-alphanumerical characters should be | |
414 | + * encoded. If QR_MODE_KANJI is given, kanji characters will be | |
415 | + * encoded as Shif-JIS characters. If QR_MODE_8 is given, all of | |
416 | + * non-alphanumerical characters will be encoded as is. If you want | |
417 | + * to embed UTF-8 string, choose this. | |
418 | + * @param casesensitive case-sensitive(1) or not(0). | |
419 | + * @return an instance of QRcode class. The version of the result QRcode may | |
420 | + * be larger than the designated version. On error, NULL is returned, | |
421 | + * and errno is set to indicate the error. See Exceptions for the | |
422 | + * details. | |
423 | + * @throw EINVAL invalid input object. | |
424 | + * @throw ENOMEM unable to allocate memory for input objects. | |
425 | + * @throw ERANGE input data is too large. | |
426 | + */ | |
427 | +extern QRcode *QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); | |
428 | + | |
429 | +/** | |
430 | + * Same to QRcode_encodeString(), but encode whole data in 8-bit mode. | |
431 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
432 | + */ | |
433 | +extern QRcode *QRcode_encodeString8bit(const char *string, int version, QRecLevel level); | |
434 | + | |
435 | +/** | |
436 | + * Micro QR Code version of QRcode_encodeString(). | |
437 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
438 | + */ | |
439 | +extern QRcode *QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); | |
440 | + | |
441 | +/** | |
442 | + * Micro QR Code version of QRcode_encodeString8bit(). | |
443 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
444 | + */ | |
445 | +extern QRcode *QRcode_encodeString8bitMQR(const char *string, int version, QRecLevel level); | |
446 | + | |
447 | +/** | |
448 | + * Encode byte stream (may include '\0') in 8-bit mode. | |
449 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
450 | + * @param size size of the input data. | |
451 | + * @param data input data. | |
452 | + * @param version version of the symbol. If 0, the library chooses the minimum | |
453 | + * version for the given input data. | |
454 | + * @param level error correction level. | |
455 | + * @throw EINVAL invalid input object. | |
456 | + * @throw ENOMEM unable to allocate memory for input objects. | |
457 | + * @throw ERANGE input data is too large. | |
458 | + */ | |
459 | +extern QRcode *QRcode_encodeData(int size, const unsigned char *data, int version, QRecLevel level); | |
460 | + | |
461 | +/** | |
462 | + * Micro QR Code version of QRcode_encodeData(). | |
463 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
464 | + */ | |
465 | +extern QRcode *QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level); | |
466 | + | |
467 | +/** | |
468 | + * Free the instance of QRcode class. | |
469 | + * @param qrcode an instance of QRcode class. | |
470 | + */ | |
471 | +extern void QRcode_free(QRcode *qrcode); | |
472 | + | |
473 | +/** | |
474 | + * Create structured symbols from the input data. | |
475 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
476 | + * @param s | |
477 | + * @return a singly-linked list of QRcode. | |
478 | + */ | |
479 | +extern QRcode_List *QRcode_encodeInputStructured(QRinput_Struct *s); | |
480 | + | |
481 | +/** | |
482 | + * Create structured symbols from the string. The library automatically parses | |
483 | + * the input string and encodes in a QR Code symbol. | |
484 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
485 | + * @param string input string. It must be NUL terminated. | |
486 | + * @param version version of the symbol. | |
487 | + * @param level error correction level. | |
488 | + * @param hint tell the library how non-alphanumerical characters should be | |
489 | + * encoded. If QR_MODE_KANJI is given, kanji characters will be | |
490 | + * encoded as Shif-JIS characters. If QR_MODE_8 is given, all of | |
491 | + * non-alphanumerical characters will be encoded as is. If you want | |
492 | + * to embed UTF-8 string, choose this. | |
493 | + * @param casesensitive case-sensitive(1) or not(0). | |
494 | + * @return a singly-linked list of QRcode. On error, NULL is returned, and | |
495 | + * errno is set to indicate the error. See Exceptions for the details. | |
496 | + * @throw EINVAL invalid input object. | |
497 | + * @throw ENOMEM unable to allocate memory for input objects. | |
498 | + */ | |
499 | +extern QRcode_List *QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive); | |
500 | + | |
501 | +/** | |
502 | + * Same to QRcode_encodeStringStructured(), but encode whole data in 8-bit mode. | |
503 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
504 | + */ | |
505 | +extern QRcode_List *QRcode_encodeString8bitStructured(const char *string, int version, QRecLevel level); | |
506 | + | |
507 | +/** | |
508 | + * Create structured symbols from byte stream (may include '\0'). Wholde data | |
509 | + * are encoded in 8-bit mode. | |
510 | + * @warning This function is THREAD UNSAFE when pthread is disabled. | |
511 | + * @param size size of the input data. | |
512 | + * @param data input dat. | |
513 | + * @param version version of the symbol. | |
514 | + * @param level error correction level. | |
515 | + * @return a singly-linked list of QRcode. On error, NULL is returned, and | |
516 | + * errno is set to indicate the error. See Exceptions for the details. | |
517 | + * @throw EINVAL invalid input object. | |
518 | + * @throw ENOMEM unable to allocate memory for input objects. | |
519 | + */ | |
520 | +extern QRcode_List *QRcode_encodeDataStructured(int size, const unsigned char *data, int version, QRecLevel level); | |
521 | + | |
522 | +/** | |
523 | + * Return the number of symbols included in a QRcode_List. | |
524 | + * @param qrlist a head entry of a QRcode_List. | |
525 | + * @return number of symbols in the list. | |
526 | + */ | |
527 | +extern int QRcode_List_size(QRcode_List *qrlist); | |
528 | + | |
529 | +/** | |
530 | + * Free the QRcode_List. | |
531 | + * @param qrlist a head entry of a QRcode_List. | |
532 | + */ | |
533 | +extern void QRcode_List_free(QRcode_List *qrlist); | |
534 | + | |
535 | + | |
536 | +/****************************************************************************** | |
537 | + * System utilities | |
538 | + *****************************************************************************/ | |
539 | + | |
540 | +/** | |
541 | + * Return a string that identifies the library version. | |
542 | + * @param major_version | |
543 | + * @param minor_version | |
544 | + * @param micro_version | |
545 | + */ | |
546 | +extern void QRcode_APIVersion(int *major_version, int *minor_version, int *micro_version); | |
547 | + | |
548 | +/** | |
549 | + * Return a string that identifies the library version. | |
550 | + * @return a string identifies the library version. The string is held by the | |
551 | + * library. Do NOT free it. | |
552 | + */ | |
553 | +extern char *QRcode_APIVersionString(void); | |
554 | + | |
555 | +/** | |
556 | + * Clear all caches. This is only for debug purpose. If you are attacking a | |
557 | + * complicated memory leak bug, try this to reduce the reachable blocks record. | |
558 | + */ | |
559 | +extern void QRcode_clearCache(void); | |
560 | + | |
561 | +#if defined(__cplusplus) | |
562 | +} | |
563 | +#endif | |
564 | + | |
565 | +#endif /* __QRENCODE_H__ */ |
@@ -17,4 +17,7 @@ HEADERS += mainwindow.h | ||
17 | 17 | |
18 | 18 | FORMS += mainwindow.ui |
19 | 19 | |
20 | +win32:INCLUDEPATH += $$PWD/QRcode-dll/ | |
21 | + | |
22 | +win32:LIBS += $$PWD/QRcode-dll/libqrencode.dll.a | |
20 | 23 | unix:LIBS += -lqrencode |
@@ -0,0 +1,77 @@ | ||
1 | +QtQREncode: qrencodeライブラリ を使ったQRコードの生成 Qt GUI ソフト | |
2 | + alucky4416@users.sourceforge.jp | |
3 | + | |
4 | +Time-stamp: "2012/10/24 22:58:52 +0900" | |
5 | + | |
6 | + qrencodeライブラリを使ったQRコード生成用のGUIアプリケーションです。 | |
7 | +qrencode 3.3.1 と QtSDK1.2.1 を使って開発しています。 | |
8 | +本ソフトのライセンスはGPLとします。 | |
9 | + | |
10 | + QRコードの生成にはqrencodeライブラリを使用しています。現在はv3.3.1を使用。 | |
11 | +http://fukuchi.org/works/qrencode/index.html.ja | |
12 | + | |
13 | + Linux用には上記のURLから、ソースを入手してライブラリをインストール | |
14 | +してください。 | |
15 | + Windows用にはlibqrencodeをDLL化したものが必要です。 | |
16 | +付属のQRcode-dll/qrencode.dllは、こちらでビルドしたものです。 | |
17 | +QRcode-dll以下のファイルはMinGW用のライブラリファイルを作成するための | |
18 | +作業用ファイルです。 | |
19 | + なお、DLL化にあたって、qrencode.c に以下の部分をファイルの末尾に追加しました。 | |
20 | +QRcode_encodeStringToU8Array()関数は私が別の用途で利用するために追加して | |
21 | +いますので、この関数が無くてもDLL作成に支障はありません。 | |
22 | +最低限必要なのはDLLMain()だけです。 | |
23 | + | |
24 | +-- ここから ------------------------------------------------------------------------------------------ | |
25 | + | |
26 | +//============================================================================== | |
27 | +// Add Function | |
28 | +__declspec(dllexport) | |
29 | +int QRcode_encodeStringToU8Array(unsigned char *instr, int instr_len, unsigned char qrcode_data[], int *qrcode_width) | |
30 | +{ | |
31 | + int casesensitive = 1; | |
32 | + int version = 0; | |
33 | + QRecLevel level = QR_ECLEVEL_L; | |
34 | + QRencodeMode hint = QR_MODE_8; | |
35 | + QRcode *code; | |
36 | + | |
37 | + if (qrcode_data == NULL || qrcode_width == NULL) return -1; | |
38 | + | |
39 | + code = QRcode_encodeData(instr_len, instr, version, level); | |
40 | + if (code == NULL) return -1; | |
41 | + | |
42 | + *qrcode_width = code->width; | |
43 | + memcpy(qrcode_data, code->data, (code->width * code->width)); // copy QRCode data | |
44 | + | |
45 | + QRcode_free(code); | |
46 | + | |
47 | + return 0; | |
48 | +} | |
49 | + | |
50 | +//============================================================================== | |
51 | +// DLL main entry-point functions | |
52 | + | |
53 | +int __stdcall DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) | |
54 | +{ | |
55 | + switch (fdwReason) { | |
56 | + case DLL_PROCESS_ATTACH: | |
57 | + break; | |
58 | + case DLL_PROCESS_DETACH: | |
59 | + break; | |
60 | + } | |
61 | + | |
62 | + return 1; | |
63 | +} | |
64 | + | |
65 | +int __stdcall DllEntryPoint (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) | |
66 | +{ | |
67 | + /* Included for compatibility with Borland */ | |
68 | + | |
69 | + return DllMain (hinstDLL, fdwReason, lpvReserved); | |
70 | +} | |
71 | +-- ここまで ------------------------------------------------------------------------------------------ | |
72 | + | |
73 | +qrencode.dllファイルはPATHの通ったフォルダか、EXEと同じ場所においてください。 | |
74 | + | |
75 | + 動作確認は、PuppyLinux 5.2.8とWindowsXPのQtCreator上で行っています。 | |
76 | +Windows用のQtSDKは、MinGW版をを使用。 | |
77 | + |