36#define INCHES_PER_METER (100.0/2.54)
52static unsigned char fg_color[4] = {0, 0, 0, 255};
53static unsigned char bg_color[4] = {255, 255, 255, 255};
77 {
"help" , no_argument , NULL,
'h'},
78 {
"output" , required_argument, NULL,
'o'},
79 {
"read-from" , required_argument, NULL,
'r'},
80 {
"level" , required_argument, NULL,
'l'},
81 {
"size" , required_argument, NULL,
's'},
82 {
"symversion" , required_argument, NULL,
'v'},
83 {
"margin" , required_argument, NULL,
'm'},
84 {
"dpi" , required_argument, NULL,
'd'},
85 {
"type" , required_argument, NULL,
't'},
86 {
"structured" , no_argument , NULL,
'S'},
87 {
"kanji" , no_argument , NULL,
'k'},
88 {
"casesensitive" , no_argument , NULL,
'c'},
89 {
"ignorecase" , no_argument , NULL,
'i'},
90 {
"8bit" , no_argument , NULL,
'8'},
91 {
"micro" , no_argument , NULL,
'M'},
92 {
"rle" , no_argument , &
rle, 1},
93 {
"svg-path" , no_argument , &
svg_path, 1},
96 {
"foreground" , required_argument, NULL,
'f'},
97 {
"background" , required_argument, NULL,
'b'},
98 {
"version" , no_argument , NULL,
'V'},
99 {
"verbose" , no_argument , &
verbose, 1},
105static void usage(
int help,
int longopt,
int status)
107 FILE *out = status ? stderr : stdout;
109"qrencode version %s\n"
114"Usage: qrencode [-o FILENAME] [OPTION]... [STRING]\n"
115"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
116" -h, --help display the help message. -h displays only the help of short\n"
118" -o FILENAME, --output=FILENAME\n"
119" write image to FILENAME. If '-' is specified, the result\n"
120" will be output to standard output. If -S is given, structured\n"
121" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
122" (suffix is removed from FILENAME, if specified)\n\n"
123" -r FILENAME, --read-from=FILENAME\n"
124" read input data from FILENAME.\n\n"
125" -s NUMBER, --size=NUMBER\n"
126" specify module size in dots (pixels). (default=3)\n\n"
127" -l {LMQH}, --level={LMQH}\n"
128" specify error correction level from L (lowest) to H (highest).\n"
130" -v NUMBER, --symversion=NUMBER\n"
131" specify the minimum version of the symbol. See SYMBOL VERSIONS\n"
132" for more information. (default=auto)\n\n"
133" -m NUMBER, --margin=NUMBER\n"
134" specify the width of the margins. (default=4 (2 for Micro QR)))\n\n"
135" -d NUMBER, --dpi=NUMBER\n"
136" specify the DPI of the generated PNG. (default=72)\n\n"
137" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8},\n"
138" --type={PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8}\n"
139" specify the type of the generated image. (default=PNG)\n\n"
141" make structured symbols. Version must be specified with '-v'.\n\n"
142" -k, --kanji assume that the input text contains kanji (shift-jis).\n\n"
143" -c, --casesensitive\n"
144" encode lower-case alphabet characters in 8-bit mode. (default)\n\n"
146" ignore case distinctions and use only upper-case characters.\n\n"
147" -8, --8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n\n"
148" -M, --micro encode in a Micro QR Code.\n\n"
149" --rle enable run-length encoding for SVG.\n\n"
151" use single path to draw modules for SVG.\n\n"
152" --inline only useful for SVG output, generates an SVG without the XML tag.\n\n"
153" --foreground=RRGGBB[AA]\n"
154" --background=RRGGBB[AA]\n"
155" specify foreground/background color in hexadecimal notation.\n"
156" 6-digit (RGB) or 8-digit (RGBA) form are supported.\n"
157" Color output support available only in PNG, EPS and SVG.\n\n"
159" disable automatic version number adjustment. If the input data is\n"
160" too large for the specified version, the program exits with the\n"
163" display the version number and copyrights of the qrencode.\n\n"
165" display verbose information to stderr.\n\n"
166" [STRING] input data. If it is not specified, data will be taken from\n"
167" standard input.\n\n"
169" The symbol versions of QR Code range from Version 1 to Version\n"
170" 40. Each version has a different module configuration or number\n"
171" of modules, ranging from Version 1 (21 x 21 modules) up to\n"
172" Version 40 (177 x 177 modules). Each higher version number\n"
173" comprises 4 additional modules per side by default. See\n"
174" http://www.qrcode.com/en/about/version.html for a detailed\n"
180"Usage: qrencode [-o FILENAME] [OPTION]... [STRING]\n"
181"Encode input data in a QR Code and save as a PNG or EPS image.\n\n"
182" -h display this message.\n"
183" --help display the usage of long options.\n"
184" -o FILENAME write image to FILENAME. If '-' is specified, the result\n"
185" will be output to standard output. If -S is given, structured\n"
186" symbols are written to FILENAME-01.png, FILENAME-02.png, ...\n"
187" (suffix is removed from FILENAME, if specified)\n"
188" -r FILENAME read input data from FILENAME.\n"
189" -s NUMBER specify module size in dots (pixels). (default=3)\n"
190" -l {LMQH} specify error correction level from L (lowest) to H (highest).\n"
192" -v NUMBER specify the minimum version of the symbol. (default=auto)\n"
193" -m NUMBER specify the width of the margins. (default=4 (2 for Micro))\n"
194" -d NUMBER specify the DPI of the generated PNG. (default=72)\n"
195" -t {PNG,PNG32,EPS,SVG,XPM,ANSI,ANSI256,ASCII,ASCIIi,UTF8,UTF8i,ANSIUTF8,ANSIUTF8i,ANSI256UTF8}\n"
196" specify the type of the generated image. (default=PNG)\n"
197" -S make structured symbols. Version number must be specified with '-v'.\n"
198" -k assume that the input text contains kanji (shift-jis).\n"
199" -c encode lower-case alphabet characters in 8-bit mode. (default)\n"
200" -i ignore case distinctions and use only upper-case characters.\n"
201" -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\n"
202" -M encode in a Micro QR Code.\n"
203" -V display the version number and copyrights of the qrencode.\n"
204" [STRING] input data. If it is not specified, data will be taken from\n"
205" standard input.\n\n"
206" Try \"qrencode --help\" for more options.\n"
212static int color_set(
unsigned char color[4],
const char *value)
214 int len = strlen(value);
218 count = sscanf(value,
"%02x%02x%02x%n", &col[0], &col[1], &col[2], &len);
219 if(count < 3 || len != 6) {
222 for(i = 0; i < 3; i++) {
226 }
else if(len == 8) {
227 count = sscanf(value,
"%02x%02x%02x%02x%n", &col[0], &col[1], &col[2], &col[3], &len);
228 if(count < 4 || len != 8) {
231 for(i = 0; i < 4; i++) {
240#define MAX_DATA_SIZE (7090 * 2)
242static unsigned char *
readFile(FILE *fp,
int *length)
248 fprintf(stderr,
"No input data.\n");
252 fprintf(stderr,
"Input data is too large.\n");
266 if(outfile == NULL || (outfile[0] ==
'-' && outfile[1] ==
'\0')) {
269 fp = fopen(outfile,
"wb");
271 fprintf(stderr,
"Failed to create file: %s\n", outfile);
281static void fillRow(
unsigned char *row,
int num,
const unsigned char color[])
285 for(i = 0; i < num; i++) {
286 memcpy(row, color, 4);
298 png_colorp palette = NULL;
299 png_byte alpha_values[2];
300 unsigned char *row, *p, *q;
301 int x, y, xx, yy, bit;
306 row = (
unsigned char *)malloc((
size_t)((realwidth + 7) / 8));
308 row = (
unsigned char *)malloc((
size_t)realwidth * 4);
310 fprintf(stderr,
"Internal error.\n");
314 fprintf(stderr,
"Failed to allocate memory.\n");
318 if(outfile[0] ==
'-' && outfile[1] ==
'\0') {
321 fp = fopen(outfile,
"wb");
323 fprintf(stderr,
"Failed to create file: %s\n", outfile);
329 png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
330 if(png_ptr == NULL) {
331 fprintf(stderr,
"Failed to initialize PNG writer.\n");
335 info_ptr = png_create_info_struct(png_ptr);
336 if(info_ptr == NULL) {
337 fprintf(stderr,
"Failed to initialize PNG write.\n");
341 if(setjmp(png_jmpbuf(png_ptr))) {
342 png_destroy_write_struct(&png_ptr, &info_ptr);
343 fprintf(stderr,
"Failed to write PNG image.\n");
348 palette = (png_colorp) malloc(
sizeof(png_color) * 2);
349 if(palette == NULL) {
350 fprintf(stderr,
"Failed to allocate memory.\n");
361 png_set_PLTE(png_ptr, info_ptr, palette, 2);
362 png_set_tRNS(png_ptr, info_ptr, alpha_values, 2, NULL);
365 png_init_io(png_ptr, fp);
367 png_set_IHDR(png_ptr, info_ptr,
368 (
unsigned int)realwidth, (
unsigned int)realwidth,
370 PNG_COLOR_TYPE_PALETTE,
372 PNG_COMPRESSION_TYPE_DEFAULT,
373 PNG_FILTER_TYPE_DEFAULT);
375 png_set_IHDR(png_ptr, info_ptr,
376 (
unsigned int)realwidth, (
unsigned int)realwidth,
378 PNG_COLOR_TYPE_RGB_ALPHA,
380 PNG_COMPRESSION_TYPE_DEFAULT,
381 PNG_FILTER_TYPE_DEFAULT);
383 png_set_pHYs(png_ptr, info_ptr,
386 PNG_RESOLUTION_METER);
387 png_write_info(png_ptr, info_ptr);
391 memset(row, 0xff, (
size_t)((realwidth + 7) / 8));
393 png_write_row(png_ptr, row);
398 for(y = 0; y < qrcode->
width; y++) {
399 memset(row, 0xff, (
size_t)((realwidth + 7) / 8));
403 for(x = 0; x < qrcode->
width; x++) {
404 for(xx = 0; xx <
size; xx++) {
405 *q ^= (*p & 1) << bit;
414 for(yy = 0; yy <
size; yy++) {
415 png_write_row(png_ptr, row);
419 memset(row, 0xff, (
size_t)((realwidth + 7) / 8));
421 png_write_row(png_ptr, row);
427 png_write_row(png_ptr, row);
432 for(y = 0; y < qrcode->
width; y++) {
434 for(x = 0; x < qrcode->
width; x++) {
435 for(xx = 0; xx <
size; xx++) {
442 for(yy = 0; yy <
size; yy++) {
443 png_write_row(png_ptr, row);
449 png_write_row(png_ptr, row);
453 png_write_end(png_ptr, info_ptr);
454 png_destroy_write_struct(&png_ptr, &info_ptr);
462 fputs(
"PNG output is disabled at compile time. No output generated.\n", stderr);
470 unsigned char *row, *p;
478 fprintf(fp,
"%%!PS-Adobe-2.0 EPSF-1.2\n"
479 "%%%%BoundingBox: 0 0 %d %d\n"
481 "%%%%EndComments\n", realwidth, realwidth);
491 fprintf(fp,
"gsave\n");
492 fprintf(fp,
"%f %f %f setrgbcolor\n",
496 fprintf(fp,
"%d %d scale\n", realwidth, realwidth);
497 fprintf(fp,
"0 0 p\ngrestore\n");
498 fprintf(fp,
"%f %f %f setrgbcolor\n",
502 fprintf(fp,
"%d %d scale\n",
size,
size);
506 for(y = 0; y < qrcode->
width; y++) {
507 row = (p+(y*qrcode->
width));
510 for(x = 0; x < qrcode->
width; x++) {
512 fprintf(fp,
"%d %d p ",
margin + x, yy);
517 fprintf(fp,
"\n%%%%EOF\n");
526 fprintf(fp,
"M%d,%dh%d", x, y, width);
529 fprintf(fp,
"\t\t\t<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"1\" "\
530 "fill=\"#%s\" fill-opacity=\"%f\"/>\n",
531 x, y, width, col, opacity );
533 fprintf(fp,
"\t\t\t<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"1\" "\
543 unsigned char *row, *p;
545 int symwidth, realwidth;
556 realwidth = symwidth *
size;
560 fg_opacity = (float)
fg_color[3] / 255;
561 bg_opacity = (float)
bg_color[3] / 255;
565 fputs(
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", fp );
577 fprintf(fp,
"<!-- Created with qrencode %s (https://fukuchi.org/works/qrencode/index.html) -->\n",
QRcode_APIVersionString());
581 "<svg width=\"%.2fcm\" height=\"%.2fcm\" viewBox=\"0 0 %d %d\""\
582 " preserveAspectRatio=\"none\" version=\"1.1\""\
583 " xmlns=\"http://www.w3.org/2000/svg\">\n",
584 realwidth / scale, realwidth / scale, symwidth, symwidth
588 fputs(
"\t<g id=\"QRcode\">\n", fp);
592 fprintf(fp,
"\t\t<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\" fill-opacity=\"%f\"/>\n", symwidth, symwidth, bg, bg_opacity);
594 fprintf(fp,
"\t\t<rect x=\"0\" y=\"0\" width=\"%d\" height=\"%d\" fill=\"#%s\"/>\n", symwidth, symwidth, bg);
599 fprintf(fp,
"\t\t<path style=\"stroke:#%s;stroke-opacity:%f\" transform=\"translate(%d,%d.5)\" d=\"", fg, fg_opacity,
margin,
margin);
601 fprintf(fp,
"\t\t<path style=\"stroke:#%s\" transform=\"translate(%d,%d.5)\" d=\"", fg,
margin,
margin);
605 fprintf(fp,
"\t\t<g id=\"Pattern\" transform=\"translate(%d,%d)\">\n",
margin,
margin);
610 for(y = 0; y < qrcode->
width; y++) {
611 row = (p+(y*qrcode->
width));
615 for(x = 0; x < qrcode->
width; x++) {
624 for(x = 0; x < qrcode->
width; x++) {
628 }
else if(!(*(row+x)&0x1)) {
643 fputs(
"\t\t</g>\n", fp);
647 fputs(
"\t</g>\n", fp);
650 fputs(
"</svg>\n", fp);
659 int x, xx, y, yy, realwidth, realmargin;
669 row = malloc((
size_t)realwidth + 1);
671 fprintf(stderr,
"Failed to allocate memory.\n");
678 fputs(
"/* XPM */\n", fp);
679 fputs(
"static const char *const qrcode_xpm[] = {\n", fp);
680 fputs(
"/* width height ncolors chars_per_pixel */\n", fp);
681 fprintf(fp,
"\"%d %d 2 1\",\n", realwidth, realwidth);
683 fputs(
"/* colors */\n", fp);
684 fprintf(fp,
"\"F c #%s\",\n", fg);
685 fprintf(fp,
"\"B c #%s\",\n", bg);
687 fputs(
"/* pixels */\n", fp);
688 memset(row,
'B', (
size_t)realwidth);
689 row[realwidth] =
'\0';
691 for (y = 0; y < realmargin; y++) {
692 fprintf(fp,
"\"%s\",\n", row);
696 for (y = 0; y < qrcode->
width; y++) {
697 for (yy = 0; yy <
size; yy++) {
700 for (x = 0; x <
margin; x++) {
701 for (xx = 0; xx <
size; xx++) {
706 for (x = 0; x < qrcode->
width; x++) {
707 for (xx = 0; xx <
size; xx++) {
708 if (p[(y * qrcode->
width) + x] & 0x1) {
716 for (x = 0; x <
margin; x++) {
717 for (xx = 0; xx <
size; xx++) {
726 for (y = 0; y < realmargin; y++) {
727 fprintf(fp,
"\"%s\"%s\n", row, y < (
size - 1) ?
"," :
"};");
737 char* buffer,
const char* white,
int white_s )
741 strncpy(buffer, white, (
size_t)white_s);
742 memset(buffer + white_s,
' ', (
size_t)realwidth * 2);
743 strcpy(buffer + white_s + realwidth * 2,
"\033[0m\n");
744 for(y = 0; y <
margin; y++ ){
752 unsigned char *row, *p;
757 const char *white, *black;
759 int white_s, black_s, buffer_s;
763 white =
"\033[48;5;231m";
765 black =
"\033[48;5;16m";
779 buffer_s = (realwidth * white_s) * 2;
780 buffer = (
char *)malloc((
size_t)buffer_s);
782 fprintf(stderr,
"Failed to allocate memory.\n");
791 for(y = 0; y < qrcode->
width; y++) {
792 row = (p+(y*qrcode->
width));
794 memset(buffer, 0, (
size_t)buffer_s);
795 strncpy(buffer, white, (
size_t)white_s);
796 for(x = 0; x <
margin; x++ ){
797 strncat(buffer,
" ", 2);
801 for(x = 0; x < qrcode->
width; x++) {
804 strncat(buffer, black, (
size_t)black_s);
807 }
else if( last != 0 ){
808 strncat(buffer, white, (
size_t)white_s);
811 strncat(buffer,
" ", 2);
815 strncat(buffer, white, (
size_t)white_s);
817 for(x = 0; x <
margin; x++ ){
818 strncat(buffer,
" ", 2);
820 strncat(buffer,
"\033[0m\n", 5);
834 const char *reset,
const char* full)
838 for (y = 0; y <
margin/2; y++) {
840 for (x = 0; x < realwidth; x++)
847static int writeUTF8(
const QRcode *qrcode,
const char *outfile,
int use_ansi,
int invert)
852 const char *white, *reset;
853 const char *empty, *lowhalf, *uphalf, *full;
856 lowhalf =
"\342\226\204";
857 uphalf =
"\342\226\200";
858 full =
"\342\226\210";
874 white =
"\033[38;5;231m\033[48;5;16m";
876 white =
"\033[40;37;1m";
892 for(y = 0; y < qrcode->
width; y += 2) {
893 unsigned char *row1, *row2;
895 row2 = row1 + qrcode->
width;
899 for (x = 0; x <
margin; x++) {
903 for (x = 0; x < qrcode->
width; x++) {
905 if(y < qrcode->width - 1 && row2[x] & 1) {
910 }
else if(y < qrcode->width - 1 && row2[x] & 1) {
917 for (x = 0; x <
margin; x++)
938 memset(buffer, (invert?
'#':
' '), (
size_t)realwidth);
939 buffer[realwidth] =
'\n';
940 buffer[realwidth + 1] =
'\0';
941 for(y = 0; y < h; y++ ){
967 buffer_s = realwidth + 2;
968 buffer = (
char *)malloc((
size_t)buffer_s);
970 fprintf(stderr,
"Failed to allocate memory.\n");
978 for(y = 0; y < qrcode->
width; y++) {
982 memset(p, white, (
size_t)
margin * 2);
985 for(x = 0; x < qrcode->
width; x++) {
995 memset(p, white, (
size_t)
margin * 2);
1030static void qrencode(
const unsigned char *intext,
int length,
const char *outfile)
1034 qrcode =
encode(intext, length);
1035 if(qrcode == NULL) {
1036 if(errno == ERANGE) {
1037 fprintf(stderr,
"Failed to encode the input data: Input data too large\n");
1039 perror(
"Failed to encode the input data");
1044 fprintf(stderr,
"Failed to encode the input data: Input data too large\n");
1049 fprintf(stderr,
"File: %s, Version: %d\n", (outfile!=NULL)?outfile:
"(stdout)", qrcode->
version);
1092 fprintf(stderr,
"Unknown image type.\n");
1115 char filename[FILENAME_MAX];
1116 char *base, *q, *suffix = NULL;
1117 const char *type_suffix;
1123 type_suffix =
".png";
1126 type_suffix =
".eps";
1129 type_suffix =
".svg";
1132 type_suffix =
".xpm";
1141 type_suffix =
".txt";
1144 fprintf(stderr,
"Unknown image type.\n");
1148 if(outfile == NULL) {
1149 fprintf(stderr,
"An output filename must be specified to store the structured images.\n");
1154 fprintf(stderr,
"Failed to allocate memory.\n");
1157 suffix_size = strlen(type_suffix);
1158 if(strlen(base) > suffix_size) {
1159 q = base + strlen(base) - suffix_size;
1160 if(strcasecmp(type_suffix, q) == 0) {
1167 if(qrlist == NULL) {
1168 if(errno == ERANGE) {
1169 fprintf(stderr,
"Failed to encode the input data: Input data too large\n");
1171 perror(
"Failed to encode the input data");
1176 for(p = qrlist; p != NULL; p = p->
next) {
1177 if(p->
code == NULL) {
1178 fprintf(stderr,
"Failed to encode the input data.\n");
1182 snprintf(filename, FILENAME_MAX,
"%s-%02d%s", base, i, suffix);
1184 snprintf(filename, FILENAME_MAX,
"%s-%02d", base, i);
1188 fprintf(stderr,
"File: %s, Version: %d\n", filename, p->
code->
version);
1232 fprintf(stderr,
"Unknown image type.\n");
1248 int opt, lindex = -1;
1249 char *outfile = NULL, *infile = NULL;
1250 unsigned char *intext = NULL;
1254 while((opt = getopt_long(argc, argv,
optstring,
options, &lindex)) != -1) {
1258 usage(1, 1, EXIT_SUCCESS);
1260 usage(1, 0, EXIT_SUCCESS);
1270 size = atoi(optarg);
1272 fprintf(stderr,
"Invalid size: %d\n",
size);
1279 fprintf(stderr,
"Invalid version: %d\n",
version);
1302 fprintf(stderr,
"Invalid level: %s\n", optarg);
1309 fprintf(stderr,
"Invalid margin: %d\n",
margin);
1316 fprintf(stderr,
"Invalid DPI: %d\n",
dpi);
1321 if(strcasecmp(optarg,
"png32") == 0) {
1323 }
else if(strcasecmp(optarg,
"png") == 0) {
1325 }
else if(strcasecmp(optarg,
"eps") == 0) {
1327 }
else if(strcasecmp(optarg,
"svg") == 0) {
1329 }
else if(strcasecmp(optarg,
"xpm") == 0) {
1331 }
else if(strcasecmp(optarg,
"ansi") == 0) {
1333 }
else if(strcasecmp(optarg,
"ansi256") == 0) {
1335 }
else if(strcasecmp(optarg,
"asciii") == 0) {
1337 }
else if(strcasecmp(optarg,
"ascii") == 0) {
1339 }
else if(strcasecmp(optarg,
"utf8") == 0) {
1341 }
else if(strcasecmp(optarg,
"ansiutf8") == 0) {
1343 }
else if(strcasecmp(optarg,
"ansi256utf8") == 0) {
1345 }
else if(strcasecmp(optarg,
"utf8i") == 0) {
1347 }
else if(strcasecmp(optarg,
"ansiutf8i") == 0) {
1350 fprintf(stderr,
"Invalid image type: %s\n", optarg);
1374 fprintf(stderr,
"Invalid foreground color value.\n");
1380 fprintf(stderr,
"Invalid background color value.\n");
1385 usage(0, 0, EXIT_SUCCESS);
1390 fprintf(stderr,
"Try \"qrencode --help\" for more information.\n");
1396 usage(1, 0, EXIT_FAILURE);
1401 fprintf(stderr,
"No output filename is given.\n");
1406 intext = (
unsigned char *)argv[optind];
1407 length = strlen((
char *)intext);
1409 if(intext == NULL) {
1410 fp = infile == NULL ? stdin : fopen(infile,
"r");
1412 fprintf(stderr,
"Cannot read input file %s.\n", infile);
1423 fprintf(stderr,
"Version number should be less or equal to %d.\n",
QRSPEC_VERSION_MAX);
1437 fprintf(stderr,
"Micro QR Code does not support structured symbols.\n");
1444 fprintf(stderr,
"Version number must be specified to encode structured symbols.\n");
static int writeUTF8(const QRcode *qrcode, const char *outfile, int use_ansi, int invert)
static int color_set(unsigned char color[4], const char *value)
static int writeEPS(const QRcode *qrcode, const char *outfile)
static int writeASCII(const QRcode *qrcode, const char *outfile, int invert)
static void writeUTF8_margin(FILE *fp, int realwidth, const char *white, const char *reset, const char *full)
static QRcode * encode(const unsigned char *intext, int length)
int main(int argc, char **argv)
static unsigned char fg_color[4]
static int writePNG(const QRcode *qrcode, const char *outfile, enum imageType type)
static int writeSVG(const QRcode *qrcode, const char *outfile)
static void writeASCII_margin(FILE *fp, int realwidth, char *buffer, int invert)
static enum imageType image_type
static void writeANSI_margin(FILE *fp, int realwidth, char *buffer, const char *white, int white_s)
static void qrencode(const unsigned char *intext, int length, const char *outfile)
static int strict_versioning
static const struct option options[]
static int writeXPM(const QRcode *qrcode, const char *outfile)
static unsigned char bg_color[4]
static void qrencodeStructured(const unsigned char *intext, int length, const char *outfile)
#define INCHES_PER_METER
qrencode - QR Code encoder
static unsigned char data_buffer[(7090 *2)]
static FILE * openFile(const char *outfile)
static void writeSVG_drawModules(FILE *fp, int x, int y, int width, const char *col, float opacity)
static int writeANSI(const QRcode *qrcode, const char *outfile)
static void usage(int help, int longopt, int status)
static QRcode_List * encodeStructured(const unsigned char *intext, int length)
static unsigned char * readFile(FILE *fp, int *length)
void QRcode_List_free(QRcode_List *qrlist)
Free the QRcode_List.
QRcode_List * QRcode_encodeStringStructured(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
Create structured symbols from the string.
QRcode * QRcode_encodeStringMQR(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
Micro QR Code version of QRcode_encodeString().
QRcode_List * QRcode_encodeDataStructured(int size, const unsigned char *data, int version, QRecLevel level)
Create structured symbols from byte stream (may include '\0').
char * QRcode_APIVersionString(void)
Return a string that identifies the library version.
QRcode * QRcode_encodeDataMQR(int size, const unsigned char *data, int version, QRecLevel level)
Micro QR Code version of QRcode_encodeData().
void QRcode_free(QRcode *qrcode)
Free the instance of QRcode class.
QRcode * QRcode_encodeData(int size, const unsigned char *data, int version, QRecLevel level)
Encode byte stream (may include '\0') in 8-bit mode.
QRcode * QRcode_encodeString(const char *string, int version, QRecLevel level, QRencodeMode hint, int casesensitive)
Create a symbol from the string.
QRecLevel
Level of error correction.
QRencodeMode
Encoding mode.
@ QR_MODE_KANJI
Kanji (shift-jis) mode.
@ QR_MODE_8
8-bit data mode
#define MQRSPEC_VERSION_MAX
Maximum version (size) of QR-code symbol.
#define QRSPEC_VERSION_MAX
Maximum version (size) of QR-code symbol.
char * strdup(const char *s)
QRcode output (qrencode.c)
int width
width of the symbol
int version
version of the symbol
unsigned char * data
symbol data
Singly-linked list of QRcode.
struct _QRcode_List * next